diff --git a/.gitignore b/.gitignore index 9bae5a1..6ea87b6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /.spago/ /.psc* /.psa* +/insect.js /docs/insect.1 /web/*.js /web/terminal.css diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 3410604..0000000 --- a/.npmignore +++ /dev/null @@ -1,14 +0,0 @@ -/.github/ -# `deploy.sh` is a local script used by @sharkdp to push the latest version of -# Insect to https://insect.sh. -/deploy.sh -/docs/*.md -/docs/*.sh -/docs/template.readme -/node_modules/ -/output -/web -/benchmarks/results/ -/benchmarks/results.json -/benchmarks/results.md -/.purs-repl diff --git a/index.js b/index.js index f7d8375..fefe501 100755 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ #!/usr/bin/env node -import * as Insect from "./output/Insect/index.js"; +import * as Insect from "./insect.js"; import * as path from "path"; var insectEnv = Insect.initialEnvironment; @@ -45,24 +45,27 @@ if (process.argv.length >= 4) { } if (process.env.INSECT_NO_RC !== "true") { - var [os, lineReader] = await Promise.all([import("os"), import("line-reader")]); + // Node 12 does not support top-level await. + (async function() { + var [os, lineReader] = await Promise.all([import("os"), import("line-reader")]); - var rcFile = path.join(os.homedir(), ".insectrc"); - lineReader.eachLine(rcFile, function (line) { - var res = runInsect(Insect.fmtPlain, line); - // We really only care when it breaks - if (res && res.msgType === "error") { - console.error(res.msg); - process.exit(1); - } - }, function (err) { - // If the file doesn't exist, that's fine - if (err && err.code !== "ENOENT") { - throw err; - } else { - startInsect(); - } - }); + var rcFile = path.join(os.homedir(), ".insectrc"); + lineReader.eachLine(rcFile, function (line) { + var res = runInsect(Insect.fmtPlain, line); + // We really only care when it breaks + if (res && res.msgType === "error") { + console.error(res.msg); + process.exit(1); + } + }, function (err) { + // If the file doesn't exist, that's fine + if (err && err.code !== "ENOENT") { + throw err; + } else { + startInsect(); + } + }); + })(); } else { startInsect(); } diff --git a/package.json b/package.json index 9e4d477..af19656 100644 --- a/package.json +++ b/package.json @@ -18,16 +18,18 @@ "test": "test" }, "files": [ - "output", + "insect.js", "web/media/insect.png" ], "scripts": { "setup": "npm run build", "start": "node copy && run-p server esbuild:watch", - "esbuild:watch": "spago build -w --then 'npm run esbuild'", - "esbuild": "esbuild output/Insect/index.js --bundle --minify --outfile=web/insect.js --target=es6 --global-name=Insect", + "esbuild:watch": "spago build -w --then 'npm run esbuild:browser'", + "esbuild": "npm run esbuild:browser && npm run esbuild:node", + "esbuild:browser": "esbuild output/Insect/index.js --bundle --minify --outfile=web/insect.js --target=es6 --global-name=Insect", + "esbuild:node": "esbuild output/Insect/index.js --bundle --minify --outfile=insect.js --target=node12 --platform=node --format=esm --external:./node_modules/*", "build": "spago build && npm run esbuild && node copy", - "prepack": "npm run build", + "prepack": "spago build && npm run esbuild:node", "server": "live-server web --open", "test": "spago test" },