Skip to content

Commit

Permalink
plugins: add flag to 'download:plugins' script
Browse files Browse the repository at this point in the history
Fixes eclipse-theia#7122

Adds the following flag to the `download:plugins` script
to control the behavior of how plugins should be packed/unpacked by
default.

The default is `false` and it means that plugins should not be preserved
as `.vsix` and instead should be unpacked. If `packed` is set to `true`
then plugins are successfully packed (kept as `.vsix`).

Signed-off-by: Vincent Fugnitto <[email protected]>
  • Loading branch information
vince-fugnitto committed Feb 11, 2020
1 parent e7b7a2b commit 92de8c3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
17 changes: 12 additions & 5 deletions dev-packages/cli/src/download-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ import * as request from 'requestretry';
import * as mkdirp from 'mkdirp';
import * as tar from 'tar';
import * as zlib from 'zlib';
export default function downloadPlugins(): void {

const unzip = require('unzip-stream');

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export default function downloadPlugins({ packed = false }: any = {}): void {

console.log('Downloading plugins...');

Expand All @@ -49,7 +53,7 @@ export default function downloadPlugins(): void {
continue;
}

const targetPath = path.join(process.cwd(), pluginsDir, plugin + fileExt);
const targetPath = path.join(process.cwd(), pluginsDir, `${plugin}${packed === true ? fileExt : ''}`);

// Skip plugins which have previously been downloaded.
if (isDownloaded(targetPath)) {
Expand Down Expand Up @@ -84,9 +88,12 @@ export default function downloadPlugins(): void {
const untar = tar.x({ cwd: targetPath });
download.pipe(gunzip).pipe(untar);
} else {
// Do not unzip .vsix files
const file = fs.createWriteStream(targetPath);
download.pipe(file);
if (packed === true) {
const file = fs.createWriteStream(targetPath);
download.pipe(file);
} else {
download.pipe(unzip.Extract({ path: targetPath }));
}
}
}
}
Expand Down
11 changes: 10 additions & 1 deletion dev-packages/cli/src/theia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,16 @@ function rebuildCommand(command: string, target: ApplicationProps.Target): yargs
})
.command({
command: 'download:plugins',
handler: () => downloadPlugins()
describe: 'Download defined external plugins.',
builder: {
'packed': {
alias: 'p',
describe: 'Controls whether to pack or unpack plugins',
boolean: true,
default: false,
}
},
handler: args => downloadPlugins(args),
}).command({
command: 'test',
builder: {
Expand Down

0 comments on commit 92de8c3

Please sign in to comment.