Skip to content

Commit

Permalink
fix: replace --asset option with --remote option (#760)
Browse files Browse the repository at this point in the history
  • Loading branch information
aral authored and calebboyd committed May 8, 2020
1 parent 01c977b commit 0a2e8db
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ compile({
- default: true
- #### `build: boolean`
- Build node from source, passing this flag tells nexe to download and build from source. Subsequently using this flag will cause nexe to use the previously built binary. To rebuild, first add [`--clean`](#clean-boolean)
- #### `asset: string`
- Provide a pre-built nexe binary asset, this can either be an http or https URL or a file path.
- #### `remote: string`
- Provide a custom remote location for fetching pre-built nexe binaries from. This can either be an HTTP or HTTPS URL or a file path.
- default: `null`
- #### `python: string`
- On Linux this is the path pointing to your python2 executable
Expand Down
21 changes: 11 additions & 10 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,18 @@ export class NexeCompiler {
//SOMEDAY iterate over multiple targets with `--outDir`
this.targets = options.targets as NexeTarget[]
this.target = this.targets[0]
if (options.asset && options.asset.startsWith('http')) {
this.remoteAsset = options.asset
} else {
if (!options.remote.startsWith('http')) {
throw new NexeError(`Invalid remote URL (must be HTTP/HTTPS): ${options.remote}`)
}
this.remoteAsset = options.remote + this.target.toString()
if (
!(
options.remote.startsWith('http://') ||
options.remote.startsWith('https://') ||
options.remote.startsWith('file://')
)
) {
throw new NexeError(
`Invalid remote URI scheme (must be http, https, or file): ${options.remote}`
)
}
this.remoteAsset = options.remote + this.target.toString()
this.src = join(this.options.temp, this.target.version)
this.configureScript = configure + (semverGt(this.target.version, '10.10.0') ? '.py' : '')
this.nodeSrcBinPath = isWindows
Expand Down Expand Up @@ -200,9 +204,6 @@ export class NexeCompiler {
}

public getNodeExecutableLocation(target?: NexeTarget) {
if (this.options.asset && !this.options.asset.startsWith('http')) {
return resolve(this.options.cwd, this.options.asset)
}
if (target) {
return join(this.options.temp, target.toString())
}
Expand Down
8 changes: 2 additions & 6 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface NexeOptions {
output: string
targets: (string | NexeTarget)[]
name: string
asset: string
remote: string
cwd: string
fs: boolean | string[]
flags: string[]
Expand All @@ -39,7 +39,6 @@ export interface NexeOptions {
native: any
mangle: boolean
ghToken: string
remote: string
sourceUrl?: string
enableStdIn?: boolean
python?: string
Expand Down Expand Up @@ -82,14 +81,12 @@ const alias = {
b: 'build',
n: 'name',
r: 'resource',
a: 'asset',
p: 'python',
f: 'flag',
c: 'configure',
m: 'make',
h: 'help',
l: 'loglevel',
e: 'remote',
'fake-argv': 'fakeArgv',
'gh-token': 'ghToken',
}
Expand All @@ -104,9 +101,8 @@ ${c.bold('nexe <entry-file> [options]')}
-t --target -- node version description
-n --name -- main app module name
-r --resource -- *embed files (glob) within the binary
-a --asset -- alternate asset path, file or url pointing to a base (nexe) binary
--remote -- alternate location (URL) to download pre-built base (nexe) binaries from
--plugin -- extend nexe runtime behavior
-e --remote -- third-party remote location (URL) to download pre-built releases from
${c.underline.bold('Building from source:')}
Expand Down

0 comments on commit 0a2e8db

Please sign in to comment.