diff --git a/package.json b/package.json index 236e4f2..da596c9 100644 --- a/package.json +++ b/package.json @@ -6,12 +6,14 @@ "main": "src/app.js", "module": "dist/diskernet.js", "bin": { - "diskernet": "build/out.cjs" + "diskernet": "build/diskernet.cjs" }, "scripts": { "start": "node src/app.js", "setup": "bash ./scripts/build_setup.sh", "build": "echo Ensure you 'npm run setup' first && bash ./scripts/compile.sh", + "compile": "npm run build", + "build-only": "bash ./scripts/build_only.sh", "clean": "rm -rf build/* bin/*", "super-clean": "npm run clean || : && rm -rf node_modules || : && rm package-lock.json", "test": "nodemon src/app.js", @@ -19,8 +21,7 @@ "serve": "nodemon src/app.js DiskerNet serve", "lint": "watch -n 5 npx eslint .", "test-hl": "node src/highlighter.js", - "postpublish": "cp package.json .package.build.json", - "prepublishOnly": "./node_modules/.bin/esbuild src/app.js --bundle --outfile=build/out.cjs --platform=node" + "prepublishOnly": "npm run build-only" }, "repository": { "type": "git", diff --git a/scripts/build_only.sh b/scripts/build_only.sh new file mode 100755 index 0000000..f854d01 --- /dev/null +++ b/scripts/build_only.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +./node_modules/.bin/esbuild src/app.js --bundle --outfile=dist/diskernet.mjs --format=esm --platform=node +./node_modules/.bin/esbuild src/app.js --bundle --outfile=build/out.cjs --platform=node +echo "#!/usr/bin/env node" > build/diskernet.js +cat build/out.cjs >> build/diskernet.js +chmod +x build/diskernet.js + diff --git a/scripts/compile.sh b/scripts/compile.sh index 2ca2158..b99eb47 100755 --- a/scripts/compile.sh +++ b/scripts/compile.sh @@ -1,10 +1,9 @@ #!/usr/bin/env bash +./scripts/build_only.sh + unset npm_config_prefix source $HOME/.nvm/nvm.sh - -./node_modules/.bin/esbuild src/app.js --bundle --outfile=build/out.cjs --platform=node - nvm use --lts pkg --compress GZip .