Remove the retain vsix option and check for absolute path (#2222)

* Clean up tasks

* Use tmp asset
This commit is contained in:
akshita31 2018-04-30 12:25:13 -07:00 коммит произвёл GitHub
Родитель 5a7727be25
Коммит 5691f27ba7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 7 добавлений и 29 удалений

Просмотреть файл

@ -8,12 +8,9 @@
import * as minimist from 'minimist'; import * as minimist from 'minimist';
import * as path from 'path'; import * as path from 'path';
let argv = minimist(process.argv.slice(2), { let argv = minimist(process.argv.slice(2));
boolean: ['retainVsix']
});
export const commandLineOptions ={ export const commandLineOptions ={
retainVsix: !!argv['retainVsix'],
outputFolder: makePathAbsolute(argv['o']), outputFolder: makePathAbsolute(argv['o']),
codeExtensionPath: makePathAbsolute(argv['codeExtensionPath']) codeExtensionPath: makePathAbsolute(argv['codeExtensionPath'])
}; };
@ -23,9 +20,5 @@ function makePathAbsolute(originalPath: string) {
return undefined; return undefined;
} }
if (path.isAbsolute(originalPath)) {
return originalPath;
}
return path.resolve(originalPath); return path.resolve(originalPath);
} }

Просмотреть файл

@ -14,7 +14,6 @@ import * as path from 'path';
import * as util from '../src/common'; import * as util from '../src/common';
import spawnNode from '../tasks/spawnNode'; import spawnNode from '../tasks/spawnNode';
import { codeExtensionPath, offlineVscodeignorePath, vscodeignorePath, vscePath, packedVsixOutputRoot } from '../tasks/projectPaths'; import { codeExtensionPath, offlineVscodeignorePath, vscodeignorePath, vscePath, packedVsixOutputRoot } from '../tasks/projectPaths';
import { commandLineOptions } from '../tasks/commandLineArguments';
import { CsharpLoggerObserver } from '../src/observers/CsharpLoggerObserver'; import { CsharpLoggerObserver } from '../src/observers/CsharpLoggerObserver';
import { EventStream } from '../src/EventStream'; import { EventStream } from '../src/EventStream';
import { getPackageJSON } from '../tasks/packageJson'; import { getPackageJSON } from '../tasks/packageJson';
@ -38,16 +37,8 @@ gulp.task('vsix:offline:package', async () => {
}); });
async function doPackageOffline() { async function doPackageOffline() {
cleanSync(true);
util.setExtensionPath(codeExtensionPath); util.setExtensionPath(codeExtensionPath);
if (commandLineOptions.retainVsix) {
//if user doesnot want to clean up the existing vsix packages
cleanSync(false);
}
else {
cleanSync(true);
}
const packageJSON = getPackageJSON(); const packageJSON = getPackageJSON();
const name = packageJSON.name; const name = packageJSON.name;
const version = packageJSON.version; const version = packageJSON.version;
@ -80,9 +71,7 @@ async function doOfflinePackage(platformInfo: PlatformInformation, packageName:
} }
cleanSync(false); cleanSync(false);
const packageFileName = `${packageName}-${platformInfo.platform}-${platformInfo.architecture}.vsix`; const packageFileName = `${packageName}-${platformInfo.platform}-${platformInfo.architecture}.vsix`;
await install(platformInfo, packageJSON); await install(platformInfo, packageJSON);
await doPackageSync(packageFileName, outputFolder); await doPackageSync(packageFileName, outputFolder);
} }

Просмотреть файл

@ -8,21 +8,19 @@ import * as glob from 'glob-promise';
import * as path from 'path'; import * as path from 'path';
import { invokeNode } from './testAssets/testAssets'; import { invokeNode } from './testAssets/testAssets';
import { PlatformInformation } from '../../src/platform'; import { PlatformInformation } from '../../src/platform';
import { rimraf } from 'async-file'; import { TmpAsset, CreateTmpDir } from '../../src/CreateTmpAsset';
import * as tmp from 'tmp';
suite("Offline packaging of VSIX", function () { suite("Offline packaging of VSIX", function () {
let vsixFiles: string[]; let vsixFiles: string[];
this.timeout(1000000); this.timeout(1000000);
let tmpDir: tmp.SynchrounousResult = null; let tmpDir: TmpAsset;
suiteSetup(() => { suiteSetup(async () => {
chai.should(); chai.should();
tmpDir = tmp.dirSync(); tmpDir = await CreateTmpDir(true);
let args: string[] = []; let args: string[] = [];
args.push(path.join("node_modules", "gulp", "bin", "gulp.js")); args.push(path.join("node_modules", "gulp", "bin", "gulp.js"));
args.push("package:offline"); args.push("package:offline");
args.push("--retainVsix");// do not delete the existing vsix in the repo
args.push(`-o`); args.push(`-o`);
args.push(tmpDir.name); args.push(tmpDir.name);
invokeNode(args); invokeNode(args);
@ -46,9 +44,7 @@ suite("Offline packaging of VSIX", function () {
suiteTeardown(async () => { suiteTeardown(async () => {
if (tmpDir) { if (tmpDir) {
await rimraf(tmpDir.name); tmpDir.dispose();
} }
tmpDir = null;
}); });
}); });