diff --git a/README.md b/README.md index 4215b97..f0ff555 100644 --- a/README.md +++ b/README.md @@ -140,24 +140,6 @@ require('asar-node/lib/autorun/index') import 'asar-node/dist/autorun-lookup.js' // 1KB minified ``` -* `node_modules/asar-node/dist/fork.js` - - `child_process.fork()` entry for bundlers. Copy it to your output path. - - ```js - // webpack.config.js - // copy node_modules/asar-node/dist/fork.js -> /path/to/fork.js - const webpack = require('webpack') - - module.exports = { - plugins: [ - new webpack.DefinePlugin({ - ASAR_NODE_FORK_ENTRY: '/path/to/fork.js' - }) - ] - } - ``` - ## Available APIs inside asar - `require('original-fs')` @@ -173,7 +155,6 @@ require('asar-node/lib/autorun/index') - `fs.createReadStream` - `child_process.execFile` - `child_process.execFileSync` -- **`child_process.fork`** - Predefine `ASAR_NODE_FORK_ENTRY` if you are using bundler ## Note diff --git a/lib/child-process.js b/lib/child-process.js index 7c592b9..833a330 100644 --- a/lib/child-process.js +++ b/lib/child-process.js @@ -6,7 +6,7 @@ const childProcess = require('child_process') let registered = false -let oldFork +// let oldFork let oldExecFile let oldExecFileSync let oldExec @@ -14,7 +14,7 @@ let oldExecSync function overwriteChildProcess () { if (registered) return - oldFork = childProcess.fork + /* oldFork = childProcess.fork childProcess.fork = function (modulePath, args, options) { if (isAsarDisabled()) { return oldFork.apply(this, arguments) @@ -41,7 +41,7 @@ function overwriteChildProcess () { path.resolve(modulePath), ...(args || []) ], options) - } + } */ oldExec = childProcess.exec childProcess.exec = invokeWithNoAsar(oldExec) @@ -111,8 +111,8 @@ function overwriteChildProcess () { function cancel () { if (!registered) return - childProcess.fork = oldFork - oldFork = undefined + // childProcess.fork = oldFork + // oldFork = undefined childProcess.exec = oldExec oldExec = undefined childProcess.execSync = oldExecSync diff --git a/package.json b/package.json index d5c05da..be22db0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "asar-node", - "version": "3.0.1", + "version": "3.1.0", "description": "Enable require('./path/to/any-node-project.asar') & require('./path/to/any-node-project.asar/any/file'). Or just run asar-node ./path/to/any-node-project.asar", "bin": { "asar-node": "./bin/asar-node.js" diff --git a/script/build.js b/script/build.js index a1914ac..cf13d2c 100644 --- a/script/build.js +++ b/script/build.js @@ -39,9 +39,9 @@ webpack([ createTarget({ 'autorun-register': [path.join(__dirname, '../lib/autorun/register.js')] }, {}, false), - createTarget({ - fork: [path.join(__dirname, '../lib/fork.js')] - }, { ASAR_NODE_FORK_ENTRY: '__filename' }, false), + // createTarget({ + // fork: [path.join(__dirname, '../lib/fork.js')] + // }, { ASAR_NODE_FORK_ENTRY: '__filename' }, false), createTarget({ 'asar-node': [path.join(__dirname, '../bin/asar-node.js')] }, {}, true) diff --git a/spec/asar-spec.js b/spec/asar-spec.js index 6bc4da7..4630e8e 100644 --- a/spec/asar-spec.js +++ b/spec/asar-spec.js @@ -1313,7 +1313,7 @@ describe('asar package', function () { }); }); - describe('child_process.fork', function () { + /* describe('child_process.fork', function () { it('opens a normal js file', function (done) { const child = ChildProcess.fork(path.join(asarDir, 'a.asar', 'ping.js')); @@ -1341,7 +1341,7 @@ describe('asar package', function () { }); child.send(file); }); - }); + }); */ describe('child_process.exec', function () { const echo = path.join(asarDir, 'echo.asar', 'echo'); @@ -1544,7 +1544,7 @@ describe('asar package', function () { describe('process.env.ELECTRON_NO_ASAR', function () { - it('disables asar support in forked processes', function (done) { + /* it('disables asar support in forked processes', function (done) { const forked = ChildProcess.fork(path.join(__dirname, 'fixtures', 'module', 'no-asar.js'), [], { env: { ELECTRON_NO_ASAR: true @@ -1559,7 +1559,7 @@ describe('asar package', function () { done(e); } }); - }); + }); */ it('disables asar support in spawned processes', function (done) { const spawned = ChildProcess.spawn(process.execPath, [path.join(__dirname, 'fixtures', 'module', 'no-asar.js')], { @@ -1661,13 +1661,13 @@ describe('asar package', function () { expect(stats.isFile()).to.be.true(); }); - ifit(true)('is available in forked scripts', async function () { + /* ifit(true)('is available in forked scripts', async function () { const child = ChildProcess.fork(path.join(fixtures, 'module', 'original-fs.js')); const message = emittedOnce(child, 'message'); child.send('message'); const [msg] = await message; expect(msg).to.equal('object'); - }); + }); */ it('can be used with streams', () => { originalFs.createReadStream(path.join(asarDir, 'a.asar'));