mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-06-13 07:10:26 +08:00
Add install all script
This commit is contained in:
26
.scripts/run-install.js
Normal file
26
.scripts/run-install.js
Normal file
@ -0,0 +1,26 @@
|
||||
// @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 {import('./samples').Sample} */ sample
|
||||
) {
|
||||
const packageJsonPath = path.join(sample.path, 'package.json');
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath).toString());
|
||||
if (packageJson['devDependencies'] || packageJson['dependencies']) {
|
||||
console.log(`=== Running install on ${path.basename(sample.path)} ===`)
|
||||
child_process.execSync(`npm install`, {
|
||||
cwd: sample.path,
|
||||
stdio: 'inherit'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for (const sample of [...samples, ...lspSamples]) {
|
||||
tryRunInstall(sample);
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
// @ts-check
|
||||
/**
|
||||
* Try running an npm script for each of the samples.
|
||||
*/
|
||||
@ -6,7 +7,7 @@ const path = require('path');
|
||||
const child_process = require('child_process');
|
||||
const { samples, lspSamples } = require('./samples')
|
||||
|
||||
async function tryLint(
|
||||
async function tryRun(
|
||||
/** @type {string} */ scriptName,
|
||||
/** @type {import('./samples').Sample} */ sample
|
||||
) {
|
||||
@ -23,5 +24,5 @@ async function tryLint(
|
||||
|
||||
const scriptName = process.argv[2];
|
||||
for (const sample of [...samples, ...lspSamples]) {
|
||||
tryLint(scriptName, sample);
|
||||
tryRun(scriptName, sample);
|
||||
}
|
||||
@ -4,6 +4,7 @@
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
"compile": "node .scripts/run-script.js compile",
|
||||
"install": "node .scripts/run-install.js",
|
||||
"lint": "node .scripts/run-script.js lint",
|
||||
"update-readme": "node .scripts/update-readme.js"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user