diff --git a/package.json b/package.json index 77834477..12a5e274 100644 --- a/package.json +++ b/package.json @@ -80,19 +80,20 @@ "tsconfig.json" ], "scripts": { - "install": "(shx test -f ./script/build.js || run-s build.js) && cross-env npm_config_build_from_source=true aminya-node-gyp-build", - "clean": "shx rm -rf ./build ./lib/ ./prebuilds ./script/*.js ./script/*.js.map ./script/*.d.ts ./script/*.tsbuildinfo", - "clean.temp": "shx rm -rf ./tmp && shx mkdir -p ./tmp", + "preinstall": "run-s build.script", + "prepare": "run-s build.library", + "clean": "shx rm -rf ./build ./lib/ ./prebuilds", + "clean.temp": "shx rm -rf ./tmp && shx mkdir -p ./tmp && shx touch ./tmp/.gitkeep", + "deploy.doc": "run-s build.doc && gh-pages --dist \"./docs\"", + "install": "aminya-node-gyp-build", "build.library": "tsc -p ./src/tsconfig.json", "build.script": "tsc -p ./script/tsconfig.json && tsc -p ./script/tsconfig.esm.json", - "build.js": "run-p build.script build.library", "build.doc": "typedoc --options ./typedoc.json && minify-all -s docs-raw -d docs --jsCompressor terser", - "deploy.doc": "run-s build.doc && gh-pages --dist \"./docs\"", - "build.prebuild": "run-s build.js && node ./script/prebuild.mjs", + "build.prebuild": "node ./script/prebuild.mjs", "build.native": "node-gyp configure --release && node-gyp configure --release -- -f compile_commands_json && node-gyp build --release", "build.native.debug": "node-gyp configure --debug && node-gyp configure --debug -- -f compile_commands_json && cross-env CMAKE_BUILD_TYPE=Debug node-gyp build --debug", - "build": "run-s build.js build.native", - "build.debug": "run-s build.js build.native.debug", + "build": "run-s build.native", + "build.debug": "run-s build.native.debug", "test.deps": "cd test && pnpm install && cd ..", "test": "run-s clean.temp test.deps build && mocha", "test.skip_gc_tests": "run-s clean.temp test.deps build.debug && cross-env SKIP_GC_TESTS=true mocha", @@ -104,8 +105,7 @@ "lint.eslint": "pnpm run lint-test.eslint --fix", "lint": "run-p lint.eslint lint.clang-format", "lint-test": "run-s lint-test.eslint", - "bench": "node --expose-gc test/bench", - "prepublishOnly": "pnpm run build.js" + "bench": "node --expose-gc test/bench" }, "keywords": [ "zeromq", diff --git a/script/build.ts b/script/build.ts index b342e18c..080fbb57 100644 --- a/script/build.ts +++ b/script/build.ts @@ -5,11 +5,13 @@ import {mkdir, cd, exec, find, mv} from "shelljs" const root = dirname(__dirname) function main() { - const zmq_rev = - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/strict-boolean-expressions - process.env.ZMQ_VERSION || "5657b4586f24ec433930e8ece02ddba7afcf0fe0" - const src_url = `https://github.com/zeromq/libzmq/archive/${zmq_rev}.tar.gz` + // Revision to use. Can be a version number like "4.3.5", a branch name, or a commit hash. + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/strict-boolean-expressions + const zmq_rev = process.env.ZMQ_VERSION || "4.3.5" + // if it looks like a dot-separated version number, prepend with "v" to match repo tagging convention + const gitref = zmq_rev.match(/^\d+\./) ? `v${zmq_rev}` : zmq_rev + const src_url = `https://github.com/zeromq/libzmq/archive/${gitref}.tar.gz` const libzmq_build_prefix = `${root}/build/libzmq-staging` const libzmq_install_prefix = `${root}/build/libzmq`