diff --git a/atom/common/api/lib/original-fs.coffee b/atom/common/api/lib/original-fs.coffee deleted file mode 100644 index e4e47f33120b..000000000000 --- a/atom/common/api/lib/original-fs.coffee +++ /dev/null @@ -1,8 +0,0 @@ -vm = require 'vm' - -# Execute the 'fs.js' and pass the 'exports' to it. -source = '(function (exports, require, module, __filename, __dirname) { ' + - process.binding('natives').originalFs + - '\n});' -fn = vm.runInThisContext source, { filename: 'fs.js' } -fn exports, require, module diff --git a/atom/common/lib/asar_init.coffee b/atom/common/lib/asar_init.coffee index 49efc902d9af..211c79ee9099 100644 --- a/atom/common/lib/asar_init.coffee +++ b/atom/common/lib/asar_init.coffee @@ -9,10 +9,10 @@ return (process, require, asarSource) -> # Make graceful-fs work with asar. source = process.binding 'natives' - source.originalFs = source.fs - source.fs = """ + source['original-fs'] = source.fs + source['fs'] = """ var src = '(function (exports, require, module, __filename, __dirname) { ' + - process.binding('natives').originalFs + + process.binding('natives')['original-fs'] + ' });'; var vm = require('vm'); var fn = vm.runInThisContext(src, { filename: 'fs.js' }); diff --git a/filenames.gypi b/filenames.gypi index cb5e37521134..adeb36466db5 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -35,7 +35,6 @@ 'atom/common/api/lib/crash-reporter.coffee', 'atom/common/api/lib/id-weak-map.coffee', 'atom/common/api/lib/native-image.coffee', - 'atom/common/api/lib/original-fs.coffee', 'atom/common/api/lib/shell.coffee', 'atom/common/lib/init.coffee', 'atom/renderer/lib/chrome-api.coffee', diff --git a/spec/asar-spec.coffee b/spec/asar-spec.coffee index d78ab4360618..3ad706b69e5a 100644 --- a/spec/asar-spec.coffee +++ b/spec/asar-spec.coffee @@ -1,6 +1,7 @@ -assert = require 'assert' -fs = require 'fs' -path = require 'path' +assert = require 'assert' +child_process = require 'child_process' +fs = require 'fs' +path = require 'path' describe 'asar package', -> fixtures = path.join __dirname, 'fixtures' @@ -443,6 +444,13 @@ describe 'asar package', -> stats = originalFs.statSync file assert stats.isFile() + it 'is available in forked scripts', (done) -> + child = child_process.fork path.join(fixtures, 'module', 'original-fs.js') + child.on 'message', (msg) -> + assert.equal msg, 'object' + done() + child.send 'message' + describe 'graceful-fs module', -> gfs = require 'graceful-fs' diff --git a/spec/fixtures/module/original-fs.js b/spec/fixtures/module/original-fs.js new file mode 100644 index 000000000000..90b6abcf9b78 --- /dev/null +++ b/spec/fixtures/module/original-fs.js @@ -0,0 +1,3 @@ +process.on('message', function (msg) { + process.send(typeof require('original-fs')); +});