diff --git a/atom/common/lib/init.coffee b/atom/common/lib/init.coffee index 5594fd8dad5f..49b1875725e0 100644 --- a/atom/common/lib/init.coffee +++ b/atom/common/lib/init.coffee @@ -43,4 +43,13 @@ asar.wrapFsWithAsar fs # Make graceful-fs work with asar. source = process.binding 'natives' source.originalFs = source.fs -source.fs = "module.exports = require('fs');" +source.fs = """ + var src = '(function (exports, require, module, __filename, __dirname) { ' + + process.binding('natives').originalFs + + ' });'; + var vm = require('vm'); + var fn = vm.runInThisContext(src, { filename: 'fs.js' }); + fn(exports, require, module); + var asar = require('#{__dirname}/asar'); + asar.wrapFsWithAsar(exports); +"""