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
|
|
|
|
2020-09-10 15:26:29 -07:00
|
|
|
async function tryRunInstall(
|
|
|
|
|
/** @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)) {
|
|
|
|
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath).toString());
|
|
|
|
|
if (packageJson['devDependencies'] || packageJson['dependencies']) {
|
|
|
|
|
console.log(`=== Running install on ${path.basename(sample.path)} ===`);
|
2020-09-10 15:26:29 -07:00
|
|
|
child_process.execSync(command, {
|
2020-01-08 22:08:36 -08:00
|
|
|
cwd: sample.path,
|
|
|
|
|
stdio: 'inherit'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
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]) {
|
2020-09-10 15:26:29 -07:00
|
|
|
tryRunInstall(command, sample);
|
2020-01-08 22:08:36 -08:00
|
|
|
}
|