Skip to content

Commit

Permalink
Skip VSIX upload if ENV vars not set (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenWeatherford authored Jul 3, 2018
1 parent e4c8ea6 commit 1d6f136
Showing 1 changed file with 30 additions and 22 deletions.
52 changes: 30 additions & 22 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const azureStorage = require('azure-storage');
const vsce = require('vsce');
const packageJson = require('./package.json');

const brightYellowFormatting = '\x1b[33m\x1b[1m%s\x1b[0m';
const brightWhiteFormatting = '\x1b[1m%s\x1b[0m';

gulp.task('package', async () => {
await vsce.createVSIX();
});
Expand All @@ -20,27 +23,32 @@ gulp.task('upload-vsix', (callback) => {
const containerName = packageJson.name;
const vsixName = `${packageJson.name}-${packageJson.version}.vsix`;
const blobPath = path.join(process.env.TRAVIS_BRANCH, process.env.TRAVIS_BUILD_NUMBER, vsixName);
const blobService = azureStorage.createBlobService(process.env.STORAGE_NAME, process.env.STORAGE_KEY);
blobService.createContainerIfNotExists(containerName, { publicAccessLevel: "blob" }, (err) => {
if (err) {
callback(err);
} else {
blobService.createBlockBlobFromLocalFile(containerName, blobPath, vsixName, (err) => {
if (err) {
callback(err);
} else {
const brightYellowFormatting = '\x1b[33m\x1b[1m%s\x1b[0m';
const brightWhiteFormatting = '\x1b[1m%s\x1b[0m';
console.log();
console.log(brightYellowFormatting, '================================================ vsix url ================================================');
console.log();
console.log(brightWhiteFormatting, blobService.getUrl(containerName, blobPath));
console.log();
console.log(brightYellowFormatting, '==========================================================================================================');
console.log();
}
});
}
});
const storageName =process.env.STORAGE_NAME;
const storageKey = process.env.STORAGE_KEY;
if (!storageName || !storageKey) {
console.log();
console.log(brightYellowFormatting, '======== Skipping upload of VSIX to storage account because STORAGE_NAME and STORAGE_KEY have not been set');
} else {
const blobService = azureStorage.createBlobService(process.env.STORAGE_NAME, process.env.STORAGE_KEY);
blobService.createContainerIfNotExists(containerName, { publicAccessLevel: "blob" }, (err) => {
if (err) {
callback(err);
} else {
blobService.createBlockBlobFromLocalFile(containerName, blobPath, vsixName, (err) => {
if (err) {
callback(err);
} else {
console.log();
console.log(brightYellowFormatting, '================================================ vsix url ================================================');
console.log();
console.log(brightWhiteFormatting, blobService.getUrl(containerName, blobPath));
console.log();
console.log(brightYellowFormatting, '==========================================================================================================');
console.log();
}
});
}
});
}
}
});

0 comments on commit 1d6f136

Please sign in to comment.