Build without pkg unless packaging

This commit is contained in:
hensm
2020-08-12 04:26:13 +01:00
committed by Matt Hensman
parent 19aaa8f27d
commit 10c92186f9
5 changed files with 125 additions and 164 deletions

View File

@@ -1,12 +1,8 @@
"use strict";
import meta from "../package.json";
import dedent from "dedent";
import path from "path";
import minimist from "minimist";
import * as daemon from "./daemon";
const argv = minimist(process.argv.slice(2), {
boolean: [ "daemon", "help", "version" ]
@@ -25,21 +21,22 @@ const argv = minimist(process.argv.slice(2), {
if (argv.version) {
console.log(meta.__applicationVersion);
// TODO: Replace this automatically
console.log(`v0.0.7`);
} else if (argv.help) {
console.log(dedent`
Usage: ${meta.__applicationExecutableName} [options]
console.log(
`Usage: ${path.basename(process.argv[0])} [options]
Options:
-h, --help Print usage info
-v, --version Print version info
-d, --daemon Launch in daemon mode. This starts a WebSocket server that
the extension can be configured to connect to under bridge
options.
-p, --port Set port number for WebSocket server. This must match the
port set in the extension options.
Options:
-h, --help Print usage info
-v, --version Print version info
-d, --daemon Launch in daemon mode. This starts a WebSocket server that
the extension can be configured to connect to under bridge
options.
-p, --port Set port number for WebSocket server. This must match the
port set in the extension options.
`);
`);
} else if (argv.daemon) {
const port = parseInt(argv.port);
if (!port || port < 1025 || port > 65535) {
@@ -47,7 +44,10 @@ if (argv.version) {
process.exit(1);
}
daemon.init(port);
import("./daemon")
.then(daemon => {
daemon.init(port);
});
} else {
import("./bridge");
}