-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathrun-all.js
More file actions
51 lines (45 loc) · 1.34 KB
/
Copy pathrun-all.js
File metadata and controls
51 lines (45 loc) · 1.34 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env node
const { execSync } = require("child_process");
const path = require("path");
const cwd = process.cwd();
const SAMPLES = [
path.join(cwd, "WidgetCounter"),
path.join(cwd, "WidgetMultiplayerCounter"),
path.join(cwd, "WidgetNotepad"),
path.join(cwd, "WidgetSimpleAnnotate"),
path.join(cwd, "WidgetTable"),
path.join(cwd, "WidgetToast"),
path.join(cwd, "WidgetUserBadge"),
path.join(cwd, "create-widget-app"),
];
const VALID_TARGETS = ["test", "update-typings"];
const target = process.argv[2];
if (!VALID_TARGETS.includes(target)) {
throw new Error(
`Invalid target: ${target}. Expected one of: ${JSON.stringify(
VALID_TARGETS
)}`
);
}
const runCommand = (command, cwd) => {
console.log(`[RUNNING] cmd=${command} in dir=${cwd}`);
return execSync(command, { cwd, encoding: "utf8" });
};
switch (target) {
case "test":
SAMPLES.forEach((dir) => {
runCommand(`npm ci`, dir);
const output = runCommand(`npm run ${target}`, dir);
if (output.includes("Error: no test specified")) {
throw new Error("no test specified");
}
console.log(output);
});
break;
case "update-typings":
SAMPLES.forEach((dir) => {
runCommand(`npm install -D @figma/plugin-typings@latest`, dir);
runCommand(`npm install -D @figma/widget-typings@latest`, dir);
});
break;
}