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
|
|
|
|
2023-04-24 14:34:53 -07:00
|
|
|
async function tryRunCommand(
|
2023-01-30 11:43:23 -08:00
|
|
|
/** @type {string} */ command,
|
2020-09-10 15:26:29 -07:00
|
|
|
/** @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)) {
|
2023-04-24 14:34:53 -07:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2020-09-10 15:26:29 -07:00
|
|
|
const command = process.argv.slice(2).join(' ');
|
2019-05-31 11:49:59 -07:00
|
|
|
for (const sample of [...samples, ...lspSamples]) {
|
2023-04-24 14:34:53 -07:00
|
|
|
tryRunCommand(command, sample);
|
2020-01-08 22:08:36 -08:00
|
|
|
}
|