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

plugins: add flag to 'download:plugins' script #7123

Merged
merged 1 commit into from
Feb 11, 2020
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
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