Skip to content

Commit

Permalink
build: fix the build with enable_run_as_node disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeykuzmin committed Nov 16, 2018
1 parent 358ca6b commit 1bee420
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion atom/app/atom_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace {
const char kRunAsNode[] = "ELECTRON_RUN_AS_NODE";
#endif

bool IsEnvSet(const char* name) {
ALLOW_UNUSED_TYPE bool IsEnvSet(const char* name) {
#if defined(OS_WIN)
size_t required_size;
getenv_s(&required_size, nullptr, 0, name);
Expand Down
5 changes: 5 additions & 0 deletions atom/common/api/features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ bool IsPDFViewerEnabled() {
return BUILDFLAG(ENABLE_PDF_VIEWER);
}

bool IsRunAsNodeEnabled() {
return BUILDFLAG(ENABLE_RUN_AS_NODE);
}

bool IsFakeLocationProviderEnabled() {
return BUILDFLAG(OVERRIDE_LOCATION_PROVIDER);
}
Expand All @@ -47,6 +51,7 @@ void Initialize(v8::Local<v8::Object> exports,
dict.SetMethod("isDesktopCapturerEnabled", &IsDesktopCapturerEnabled);
dict.SetMethod("isOffscreenRenderingEnabled", &IsOffscreenRenderingEnabled);
dict.SetMethod("isPDFViewerEnabled", &IsPDFViewerEnabled);
dict.SetMethod("isRunAsNodeEnabled", &IsRunAsNodeEnabled);
dict.SetMethod("isFakeLocationProviderEnabled",
&IsFakeLocationProviderEnabled);
dict.SetMethod("isViewApiEnabled", &IsViewApiEnabled);
Expand Down
7 changes: 7 additions & 0 deletions spec/asar-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const remote = require('electron').remote
const ipcMain = remote.require('electron').ipcMain
const BrowserWindow = remote.require('electron').BrowserWindow

const features = process.atomBinding('features')

describe('asar package', function () {
const fixtures = path.join(__dirname, 'fixtures')

Expand Down Expand Up @@ -1043,6 +1045,11 @@ describe('asar package', function () {
})

it('disables asar support in spawned processes', function (done) {
if (!features.isRunAsNodeEnabled()) {
this.skip()
done()
}

const spawned = ChildProcess.spawn(process.execPath, [path.join(__dirname, 'fixtures', 'module', 'no-asar.js')], {
env: {
ELECTRON_NO_ASAR: true,
Expand Down
22 changes: 19 additions & 3 deletions spec/node-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const fs = require('fs')
const path = require('path')
const os = require('os')
const { ipcRenderer, remote } = require('electron')
const features = process.atomBinding('features')

const isCI = remote.getGlobal('isCi')
chai.use(dirtyChai)
Expand Down Expand Up @@ -113,7 +114,12 @@ describe('node feature', () => {
if (child != null) child.kill()
})

it('supports spawning Electron as a node process via the ELECTRON_RUN_AS_NODE env var', (done) => {
it('supports spawning Electron as a node process via the ELECTRON_RUN_AS_NODE env var', function (done) {
if (!features.isRunAsNodeEnabled()) {
this.skip()
done()
}

child = ChildProcess.spawn(process.execPath, [path.join(__dirname, 'fixtures', 'module', 'run-as-node.js')], {
env: {
ELECTRON_RUN_AS_NODE: true
Expand Down Expand Up @@ -212,7 +218,12 @@ describe('node feature', () => {
if (child !== null) child.kill()
})

it('supports starting the v8 inspector with --inspect/--inspect-brk', (done) => {
it('supports starting the v8 inspector with --inspect/--inspect-brk', function (done) {
if (!features.isRunAsNodeEnabled()) {
this.skip()
done()
}

child = ChildProcess.spawn(process.execPath, ['--inspect-brk', path.join(__dirname, 'fixtures', 'module', 'run-as-node.js')], {
env: {
ELECTRON_RUN_AS_NODE: true
Expand All @@ -239,7 +250,12 @@ describe('node feature', () => {
child.stdout.on('data', outDataHandler)
})

it('supports js binding', (done) => {
it('supports js binding', function (done) {
if (!features.isRunAsNodeEnabled()) {
this.skip()
done()
}

child = ChildProcess.spawn(process.execPath, ['--inspect', path.join(__dirname, 'fixtures', 'module', 'inspector-binding.js')], {
env: {
ELECTRON_RUN_AS_NODE: true
Expand Down

0 comments on commit 1bee420

Please sign in to comment.