mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-04-27 16:55:44 +08:00
31 lines
906 B
JavaScript
31 lines
906 B
JavaScript
// @ts-check
|
|
/**
|
|
* Try running install for all the samples
|
|
*/
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const child_process = require('child_process');
|
|
const { samples, lspSamples } = require('./samples');
|
|
|
|
async function tryRunInstall(
|
|
/** @type {string} */ command,
|
|
/** @type {import('./samples').Sample} */ sample,
|
|
) {
|
|
const packageJsonPath = path.join(sample.path, 'package.json');
|
|
if (fs.existsSync(packageJsonPath)) {
|
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath).toString());
|
|
if (packageJson['devDependencies'] || packageJson['dependencies']) {
|
|
console.log(`=== Running ${command} on ${path.basename(sample.path)} ===`);
|
|
child_process.execSync(command, {
|
|
cwd: sample.path,
|
|
stdio: 'inherit'
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
const command = process.argv.slice(2).join(' ');
|
|
for (const sample of [...samples, ...lspSamples]) {
|
|
tryRunInstall(command, sample);
|
|
}
|