Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

promise to await: packaging tasks #2164

Merged
merged 1 commit into from
Apr 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 17 additions & 28 deletions tasks/offlinePackagingTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,18 @@ import { getPackageJSON } from '../tasks/packageJson';
import { Logger } from '../src/logger';
import { PackageManager } from '../src/packages';
import { PlatformInformation } from '../src/platform';
import { Result } from 'async-child-process';

gulp.task('vsix:offline:package', async () => {
del.sync(vscodeignorePath);

fs.copyFileSync(offlineVscodeignorePath, vscodeignorePath);

return doPackageOffline()
.then(async v => del(vscodeignorePath),
e => {
del(vscodeignorePath);
throw e;
});
try {
await doPackageOffline();
}
finally {
del(vscodeignorePath);
}
});

async function doPackageOffline() {
Expand All @@ -58,14 +57,9 @@ async function doPackageOffline() {
new PlatformInformation('linux', 'x86_64')
];

let promise = Promise.resolve<Result>(null);

packages.forEach(platformInfo => {
promise = promise
.then(async () => doOfflinePackage(platformInfo, packageName, packageJSON, packedVsixOutputRoot));
});

return promise;
for (let platformInfo of packages) {
await doOfflinePackage(platformInfo, packageName, packageJSON, packedVsixOutputRoot);
}
}

function cleanSync(deleteVsix: boolean) {
Expand All @@ -85,8 +79,10 @@ async function doOfflinePackage(platformInfo: PlatformInformation, packageName:

cleanSync(false);

return install(platformInfo, packageJSON)
.then(async () => doPackageSync(packageName + '-' + platformInfo.platform + '-' + platformInfo.architecture + '.vsix', outputFolder));
const packageFileName = `${packageName}-${platformInfo.platform}-${platformInfo.architecture}.vsix`;

await install(platformInfo, packageJSON);
await doPackageSync(packageFileName, outputFolder);
}

// Install Tasks
Expand All @@ -98,17 +94,10 @@ async function install(platformInfo: PlatformInformation, packageJSON: any) {
eventStream.subscribe(stdoutObserver.post);
const debuggerUtil = new debugUtil.CoreClrDebugUtil(path.resolve('.'));

return packageManager.DownloadPackages(eventStream, undefined, undefined, undefined)
.then(async () => {
return packageManager.InstallPackages(eventStream, undefined);
})
.then(async () => {

return util.touchInstallFile(util.InstallFileType.Lock);
})
.then(async () => {
return debugUtil.CoreClrDebugUtil.writeEmptyFile(debuggerUtil.installCompleteFilePath());
});
await packageManager.DownloadPackages(eventStream, undefined, undefined, undefined);
await packageManager.InstallPackages(eventStream, undefined);
await util.touchInstallFile(util.InstallFileType.Lock);
await debugUtil.CoreClrDebugUtil.writeEmptyFile(debuggerUtil.installCompleteFilePath());
}

/// Packaging (VSIX) Tasks
Expand Down
13 changes: 6 additions & 7 deletions tasks/onlinePackagingTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ gulp.task('vsix:release:package', async (onError) => {

fs.copyFileSync(onlineVscodeignorePath, vscodeignorePath);

return spawnNode([vscePath, 'package'])
.then(() => {
del(vscodeignorePath);
}, (error) => {
del(vscodeignorePath);
throw error;
});
try {
await spawnNode([vscePath, 'package']);
}
finally {
await del(vscodeignorePath);
}
});