Run `npm install` when `node make *` on fresh install
const crypto = require("crypto")
-const semver = require("semver")
const cp = require("child_process")
const fs = require("fs")
+function npm_install() {
+ const {status} = cp.spawnSync("npm", ["install"], {stdio: "inherit"})
+ if (status !== 0)
+ process.exit(status)
+}
+
+if (!fs.existsSync("node_modules/")) {
+ console.log("New development environment. Running `npm install`.")
+ npm_install()
+}
+
const {engines} = require("../package.json")
const node_version = process.version
const npm_version = cp.execSync("npm --version").toString().trim()
+const semver = require("semver")
+
if (!semver.satisfies(node_version, engines.node)) {
console.log(`node ${engines.node} is required. Current version is ${node_version}.`)
process.exit(1)
@@ -35,9 +47,7 @@ function is_up_to_date(file) {
if (!is_up_to_date("package.json")) {
console.log("package.json has changed. Running `npm install`.")
- const {status} = cp.spawnSync("npm", ["install"], {stdio: "inherit"})
- if (status !== 0)
- process.exit(status)
+ npm_install()
}
const {register, TSError} = require("ts-node")
