-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathconfig-common.js
More file actions
26 lines (23 loc) · 855 Bytes
/
config-common.js
File metadata and controls
26 lines (23 loc) · 855 Bytes
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
import {spawnSync} from "child_process";
export function isDev() {
return process.env.NODE_ENV !== "production";
}
export function printSbtTask(task, devMode) {
const buildModeArg = !!devMode ? "-Dbuild-mode=dev" : "-Dbuild-mode=prod";
const args = [buildModeArg, "--error", "--batch", `print ${task}`];
const options = {
stdio: [
"pipe", // StdIn.
"pipe", // StdOut.
"inherit", // StdErr.
],
};
const result = process.platform === 'win32'
? spawnSync("sbt.bat", args.map(x => `"${x}"`), {shell: true, ...options})
: spawnSync("sbt", args, options);
if (result.error)
throw result.error;
if (result.status !== 0)
throw new Error(`sbt process failed with exit code ${result.status}`);
return result.stdout.toString('utf8').trim();
}