-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
29 lines (24 loc) · 782 Bytes
/
cli.js
File metadata and controls
29 lines (24 loc) · 782 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
27
28
29
#!/usr/bin/env node
const fs = require("fs");
const path = require("path");
const os = require("os");
// Copy index.js in temp folder
const tempFolder = fs.mkdtempSync(path.join(os.tmpdir(), "webopen-"));
const sourceIndexFile = path.join(__dirname, "index.js");
const destinationIndexFile = path.join(tempFolder, "index.js");
fs.copyFileSync(sourceIndexFile, destinationIndexFile);
// Set location of index.js
const args = process.argv.slice(2);
args.unshift(tempFolder);
// From https://github.com/nexe/nexe/issues/605#issuecomment-480631784
const childProcess = require("child_process").fork(
require.resolve("deskgap/cli.js"),
args,
{
stdio: "inherit",
}
);
childProcess.on("exit", () => {
fs.unlinkSync(destinationIndexFile);
fs.rmdirSync(tempFolder);
});