From 8897a7a92671701b2aa04af82256e31a376f6112 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Oct 2016 10:59:18 -0700 Subject: [PATCH] Add specs for ELECTRON_NO_ASAR env var --- spec/asar-spec.js | 35 +++++++++++++++++++++++++++++++++ spec/fixtures/module/no-asar.js | 15 ++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 spec/fixtures/module/no-asar.js diff --git a/spec/asar-spec.js b/spec/asar-spec.js index 9b53a3ffbdf4..8b5e741be176 100644 --- a/spec/asar-spec.js +++ b/spec/asar-spec.js @@ -753,6 +753,41 @@ describe('asar package', function () { assert.equal(process.noAsar, false) }) }) + + describe('process.env.ELECTRON_NO_ASAR', function () { + 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 + } + }) + forked.on('message', function (stats) { + assert.equal(stats.isFile, true) + assert.equal(stats.size, 778) + done() + }) + }) + + it('disables asar support in spawned processes', function (done) { + const spawned = ChildProcess.spawn(process.execPath, [path.join(__dirname, 'fixtures', 'module', 'no-asar.js')], { + env: { + ELECTRON_NO_ASAR: true, + ELECTRON_RUN_AS_NODE: true + } + }) + + let output = '' + spawned.stdout.on('data', function (data) { + output += data + }) + spawned.stdout.on('close', function () { + stats = JSON.parse(output) + assert.equal(stats.isFile, true) + assert.equal(stats.size, 778) + done() + }) + }) + }) }) describe('asar protocol', function () { diff --git a/spec/fixtures/module/no-asar.js b/spec/fixtures/module/no-asar.js new file mode 100644 index 000000000000..e574e3c6511b --- /dev/null +++ b/spec/fixtures/module/no-asar.js @@ -0,0 +1,15 @@ +const fs = require('fs') +const path = require('path') + +const stats = fs.statSync(path.join(__dirname, '..', 'asar', 'a.asar')) + +const details = { + isFile: stats.isFile(), + size: stats.size +} + +if (process.send != null) { + process.send(details) +} else { + console.log(JSON.stringify(details)) +}