Files
vscode-extension-samples/.scripts/run-command.js

35 lines
963 B
JavaScript
Raw Permalink Normal View History

2019-05-31 11:49:59 -07:00
// @ts-check
/**
* Try running install for all the samples
*/
const fs = require('fs');
const path = require('path');
const child_process = require('child_process');
2020-01-08 22:08:36 -08:00
const { samples, lspSamples } = require('./samples');
2019-05-31 11:49:59 -07:00
async function tryRunCommand(
/** @type {string} */ command,
/** @type {import('./samples').Sample} */ sample,
) {
2020-01-08 22:08:36 -08:00
const packageJsonPath = path.join(sample.path, 'package.json');
if (fs.existsSync(packageJsonPath)) {
try {
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'
});
}
} catch (e) {
console.error(e);
2020-01-08 22:08:36 -08:00
}
}
2019-05-31 11:49:59 -07:00
}
const command = process.argv.slice(2).join(' ');
2019-05-31 11:49:59 -07:00
for (const sample of [...samples, ...lspSamples]) {
tryRunCommand(command, sample);
2020-01-08 22:08:36 -08:00
}