-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjam.mjs
executable file
·43 lines (37 loc) · 1005 Bytes
/
jam.mjs
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
#!/usr/bin/env node
import entrypoint from './src/entrypoint.mjs';
import * as constants from './src/constants.mjs';
import { enable as enableDiagnostics } from './src/diagnostics.js';
enableDiagnostics();
const run = async (argv, cwd) => {
console.log('📻 Jambox 📻');
const script = process.argv.slice(2);
if (!script.length) {
console.log('Nothing to run');
process.exit(0);
}
entrypoint({
script,
cwd,
log: console.log,
env: process.env,
constants,
})
.then((result) => {
if (result.browser) {
console.log('Browser launched');
// TODO: Figure out why spawning the browser process leaves
// our original node process running.
// Maybe we should always exit even for process launches
process.exit(0);
}
if (result.process) {
console.log('Process launched');
}
})
.catch((e) => {
console.log(e);
process.exit(1);
});
};
run(process.argv, process.cwd());