From 058c34ee8af2dd31b66c5c3433cf5747b24699eb Mon Sep 17 00:00:00 2001 From: calebboyd Date: Wed, 21 Nov 2018 18:31:06 -0600 Subject: [PATCH] chore: update node-cli patches for 10-10.9 --- .circleci/build.sh | 2 +- .circleci/setup.sh | 7 +++---- README.md | 14 ++++++-------- src/compiler.ts | 6 ++++-- src/patches/disable-node-cli.ts | 15 ++++++++++++++- 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/.circleci/build.sh b/.circleci/build.sh index af19e8b..d2980d3 100755 --- a/.circleci/build.sh +++ b/.circleci/build.sh @@ -5,4 +5,4 @@ export NVS_HOME="$HOME/.nvs" set -e -x -yarn run asset-compile +npm run asset-compile diff --git a/.circleci/setup.sh b/.circleci/setup.sh index 1797b2c..897a3cb 100755 --- a/.circleci/setup.sh +++ b/.circleci/setup.sh @@ -1,11 +1,10 @@ #!/usr/bin/env bash set -e -echo "setting up node to use latest lts" - export NVS_HOME="$HOME/.nvs" git clone --depth=1 https://github.com/jasongin/nvs "$NVS_HOME" . "$NVS_HOME/nvs.sh" install nvs add lts && nvs link lts nvs use default -npm install -g yarn -yarn +node -v +npm -v +npm ci diff --git a/README.md b/README.md index 88bcf15..818e248 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ Downloads Version License -

npm i nexe -g

@@ -43,7 +42,6 @@ For more CLI options see: `nexe --help` ### Examples - `nexe server.js -r "public/**/*.html"` -- `nexe my-bundle.js --no-bundle -o app.exe` - `nexe --build` - `nexe -t x86-8.0.0` @@ -90,14 +88,14 @@ compile({ - Output executable file path - default: same as `name` with an OS specific extension. - #### `target: string | object` - - An object or string describing platform-arch-version. e.g. `'windows-ia32-6.10.3'` + - An object or string describing platform-arch-version. e.g. `'windows-ia32-10.13.0'` - each segment is optional, and will be merged with the current environment - Examples: ([full list](https://github.com/nexe/nexe/releases)) - - `'win32-x86-8.6.0` + - `'win32-x86-10.13.0` - `{ platform: 'alpine' }` - - `darwin-8.6.0` + - `darwin-10.13.0` - `linux-x64` - - `macos-8.4.0` + - `macos-10.13.0` See [test/target.spec.ts](test/target.spec.ts) - If the [`build`](#build-boolean) flag is set, the platform portion of the target is ignored. @@ -145,12 +143,12 @@ compile({ - #### `temp: string` - Path to use for storing nexe's build files - Override in the env with `NEXE_TEMP` - - default: `./.nexe` in the cwd + - default: `~/.nexe` - #### `ico: string` - Path to a user provided icon to be used (Windows only). Requires `--build` to be set. - #### `rc: object` - Settings for patching the [node.rc](https://github.com/nodejs/node/blob/master/src/res/node.rc) configuration file (Windows only). - - Example: + - Example (keys may vary depending ont the version. Reference the file linked above): ```javascript { CompanyName: "ACME Corp", diff --git a/src/compiler.ts b/src/compiler.ts index 7a83610..06628ae 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -26,6 +26,8 @@ const isBsd = Boolean(~process.platform.indexOf('bsd')) const make = isWindows ? 'vcbuild.bat' : isBsd ? 'gmake' : 'make' const configure = isWindows ? 'configure' : './configure' +type StringReplacer = (match: string) => string + export interface NexeFile { filename: string absPath: string @@ -155,9 +157,9 @@ export class NexeCompiler { } @bound - async replaceInFileAsync(file: string, replace: string | RegExp, value: string) { + async replaceInFileAsync(file: string, replace: string | RegExp, value: string | StringReplacer) { const entry = await this.readFileAsync(file) - entry.contents = entry.contents.replace(replace, value) + entry.contents = entry.contents.replace(replace, value as any) } @bound diff --git a/src/patches/disable-node-cli.ts b/src/patches/disable-node-cli.ts index 65c20da..7996a28 100644 --- a/src/patches/disable-node-cli.ts +++ b/src/patches/disable-node-cli.ts @@ -6,8 +6,21 @@ export default async function disableNodeCli(compiler: NexeCompiler, next: () => return next() } - if (semverGt(compiler.target.version, '9.99')) { + if (semverGt(compiler.target.version, '10.9')) { await compiler.replaceInFileAsync('src/node.cc', /(? 1/g, match => { + if (matches++) { + return 'false' + } + return match + }) } else { const nodeccMarker = 'argv[index][0] =='