Npm Audit fixes

Also fixes run-command to not stop if it fails on one sample
This commit is contained in:
Matt Bierner
2023-04-24 14:34:53 -07:00
parent f7b27a9177
commit 01f2f6d736
10 changed files with 1846 additions and 1875 deletions

View File

@ -7,24 +7,28 @@ const path = require('path');
const child_process = require('child_process');
const { samples, lspSamples } = require('./samples');
async function tryRunInstall(
async function tryRunCommand(
/** @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'
});
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);
}
}
}
const command = process.argv.slice(2).join(' ');
for (const sample of [...samples, ...lspSamples]) {
tryRunInstall(command, sample);
tryRunCommand(command, sample);
}