forked from AssemblyScript/assemblyscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasc.js
33 lines (29 loc) · 907 Bytes
/
asc.js
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
#!/usr/bin/env node
const [ nodePath, thisPath, ...args ] = process.argv;
const nodeArgs = process.execArgv;
const hasSourceMaps = nodeArgs.includes("--enable-source-maps");
const posCustomArgs = args.indexOf("--");
const isDeno = typeof Deno !== "undefined";
if (isDeno) {
process.on = function() { /* suppress 'not implemented' message */ };
}
if ((!hasSourceMaps || ~posCustomArgs) && !isDeno) {
if (!hasSourceMaps) {
nodeArgs.push("--enable-source-maps");
}
if (~posCustomArgs) {
nodeArgs.push(...args.slice(posCustomArgs + 1));
args.length = posCustomArgs;
}
(await import("child_process")).spawnSync(
nodePath,
[...nodeArgs, thisPath, ...args],
{ stdio: "inherit" }
);
} else {
const { error } = (await import("../dist/asc.js")).main(process.argv.slice(2), {
stdout: process.stdout,
stderr: process.stderr
});
if (error) process.exitCode = 1;
}