diff --git a/package-lock.json b/package-lock.json index c29dec1..afb8e65 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "nexe", - "version": "3.0.3", + "version": "3.0.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index dd1c0a5..77a2ab0 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": "3.0.3", + "version": "3.0.4", "contributors": [ "Craig Condon (http://crcn.io)", "Jared Allard ", diff --git a/src/fs/patch.ts b/src/fs/patch.ts index cc8428d..08a72b1 100644 --- a/src/fs/patch.ts +++ b/src/fs/patch.ts @@ -31,14 +31,15 @@ function shimFs(binary: NexeBinary, fs: any = require('fs')) { } originalFsMethods = Object.assign({}, fs) nexeBinary = binary - const { blobPath, resources: manifest } = binary - const { resourceStart, stat } = binary.layout - const directories: { [key: string]: { [key: string]: boolean } } = {}, + const { blobPath, resources: manifest } = binary, + { resourceStart, stat } = binary.layout, + directories: { [key: string]: { [key: string]: boolean } } = {}, notAFile = '!@#$%^&*', isWin = process.platform.startsWith('win'), isString = (x: any): x is string => typeof x === 'string' || x instanceof String, noop = () => {}, - path = require('path') + path = require('path'), + baseDir = path.dirname(process.execPath) let log = (text: string) => true if ((process.env.DEBUG || '').toLowerCase().includes('nexe:require')) { @@ -52,7 +53,7 @@ function shimFs(binary: NexeBinary, fs: any = require('fs')) { if (!isString(filepath)) { return notAFile } - let key = path.resolve(filepath) + let key = path.resolve(baseDir, filepath) if (isWin && key.substr(1, 2) === ':\\') { key = key[0].toUpperCase() + key.substr(1) diff --git a/src/steps/shim.ts b/src/steps/shim.ts index 8dc4c67..fd225b8 100644 --- a/src/steps/shim.ts +++ b/src/steps/shim.ts @@ -22,7 +22,11 @@ export default function(compiler: NexeCompiler, next: () => Promise) { compiler.shims.push( wrap(` if (!process.send) { - process.argv.splice(1,0, require.resolve(${JSON.stringify(compiler.entrypoint)})) + const path = require('path') + const entry = path.resolve(path.dirname(process.execPath),${JSON.stringify( + compiler.entrypoint + )}) + process.argv.splice(1,0, entry) } `) )