-
Notifications
You must be signed in to change notification settings - Fork 60
/
npm-prepare.cjs
33 lines (29 loc) · 812 Bytes
/
npm-prepare.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* @fileoverview Install examples' dependencies as part of local npm install for
* development and CI.
* @author btmills
*/
"use strict";
if (!process.env.NO_RECURSIVE_PREPARE) {
const childProcess = require("node:child_process");
const fs = require("node:fs");
const path = require("node:path");
const examplesDir = path.resolve(__dirname, "examples");
const examples = fs
.readdirSync(examplesDir)
.filter(exampleDir =>
fs.statSync(path.join(examplesDir, exampleDir)).isDirectory(),
)
.filter(exampleDir =>
fs.existsSync(path.join(examplesDir, exampleDir, "package.json")),
);
for (const example of examples) {
childProcess.execSync("npm install", {
cwd: path.resolve(examplesDir, example),
env: {
...process.env,
NO_RECURSIVE_PREPARE: "true",
},
});
}
}