diff --git a/README.md b/README.md index ebd2584..937693e 100644 --- a/README.md +++ b/README.md @@ -164,6 +164,10 @@ compile({ - default: `false` - #### `fakeArgv: boolean` - fake the entry point file name (`process.argv[1]`). If nexe was used with stdin this will be `'[stdin]'`. + - #### `ghToken: string` + - Provide a Github Token for accessing nexe releases + - This is usually needed in CI environments + - default: `process.env.GITHUB_TOKEN` - #### `sourceUrl: string` - Provide an alternate url for the node source code - Note: temporary files will still be created for this under the specified version diff --git a/package.json b/package.json index 26a9c23..ccdb8c8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "nexe", "description": "Create a single executable out of your Node.js application", "license": "MIT", - "version": "2.0.0-rc.20", + "version": "2.0.0-rc.21", "contributors": [ "Craig Condon (http://crcn.io)", "Jared Allard ", diff --git a/src/compiler.ts b/src/compiler.ts index 3718400..6a486ac 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -185,6 +185,9 @@ export class NexeCompiler { 'User-Agent': 'nexe (https://www.npmjs.com/package/nexe)' } } + if (this.options.ghToken) { + downloadOptions.headers.Authorization = 'token ' + this.options.ghToken + } const githubRelease = await getLatestGitRelease(downloadOptions) const assetName = target.toString() const asset = githubRelease.assets.find(x => x.name === assetName) diff --git a/src/options.ts b/src/options.ts index 77be0a6..7a7f958 100644 --- a/src/options.ts +++ b/src/options.ts @@ -33,6 +33,7 @@ export interface NexeOptions { plugins: (string | NexePatch)[] native: any empty: boolean + ghToken: string sourceUrl?: string enableStdIn?: boolean python?: string @@ -81,7 +82,8 @@ const alias = { m: 'make', h: 'help', l: 'loglevel', - 'fake-argv': 'fakeArgv' + 'fake-argv': 'fakeArgv', + 'gh-token': 'ghToken', } const argv = parseArgv(process.argv, { alias, default: { ...defaults, enableStdIn: true } }) const g = c.gray @@ -221,6 +223,7 @@ function normalizeOptions(input?: Partial): NexeOptions { if (!options.targets.length) { options.targets.push(getTarget()) } + options.ghToken = options.ghToken || process.env.GITHUB_TOKEN || '' options.make = flatten(options.vcBuild, options.make) options.configure = flatten(options.configure) options.resources = flatten(opts.resource, options.resources)