mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
build: fix the build with enable_run_as_node disabled (#16367)
This commit is contained in:
@@ -47,7 +47,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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -43,6 +47,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);
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -845,6 +847,12 @@ describe('asar package', function () {
|
||||
})
|
||||
|
||||
describe('child_process.fork', function () {
|
||||
before(function () {
|
||||
if (!features.isRunAsNodeEnabled()) {
|
||||
this.skip()
|
||||
}
|
||||
})
|
||||
|
||||
it('opens a normal js file', function (done) {
|
||||
const child = ChildProcess.fork(path.join(fixtures, 'asar', 'a.asar', 'ping.js'))
|
||||
child.on('message', function (msg) {
|
||||
@@ -1029,6 +1037,12 @@ describe('asar package', function () {
|
||||
})
|
||||
|
||||
describe('process.env.ELECTRON_NO_ASAR', function () {
|
||||
before(function () {
|
||||
if (!features.isRunAsNodeEnabled()) {
|
||||
this.skip()
|
||||
}
|
||||
})
|
||||
|
||||
it('disables asar support in forked processes', function (done) {
|
||||
const forked = ChildProcess.fork(path.join(__dirname, 'fixtures', 'module', 'no-asar.js'), [], {
|
||||
env: {
|
||||
@@ -1185,6 +1199,11 @@ describe('asar package', function () {
|
||||
})
|
||||
|
||||
it('is available in forked scripts', function (done) {
|
||||
if (!features.isRunAsNodeEnabled()) {
|
||||
this.skip()
|
||||
done()
|
||||
}
|
||||
|
||||
const child = ChildProcess.fork(path.join(fixtures, 'module', 'original-fs.js'))
|
||||
child.on('message', function (msg) {
|
||||
assert.strictEqual(msg, 'object')
|
||||
|
||||
@@ -5,6 +5,7 @@ const fs = require('fs')
|
||||
const { remote } = require('electron')
|
||||
const { BrowserWindow } = remote
|
||||
const { closeWindow } = require('./window-helpers')
|
||||
const features = process.atomBinding('features')
|
||||
|
||||
const nativeModulesEnabled = remote.getGlobal('nativeModulesEnabled')
|
||||
|
||||
@@ -17,7 +18,12 @@ describe('modules support', () => {
|
||||
require('runas')
|
||||
})
|
||||
|
||||
it('can be required in node binary', (done) => {
|
||||
it('can be required in node binary', function (done) {
|
||||
if (!features.isRunAsNodeEnabled()) {
|
||||
this.skip()
|
||||
done()
|
||||
}
|
||||
|
||||
const runas = path.join(fixtures, 'module', 'runas.js')
|
||||
const child = require('child_process').fork(runas)
|
||||
child.on('message', (msg) => {
|
||||
|
||||
@@ -5,6 +5,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')
|
||||
|
||||
@@ -12,6 +13,12 @@ describe('node feature', () => {
|
||||
const fixtures = path.join(__dirname, 'fixtures')
|
||||
|
||||
describe('child_process', () => {
|
||||
beforeEach(function () {
|
||||
if (!features.isRunAsNodeEnabled()) {
|
||||
this.skip()
|
||||
}
|
||||
})
|
||||
|
||||
describe('child_process.fork', () => {
|
||||
it('works in current process', (done) => {
|
||||
const child = ChildProcess.fork(path.join(fixtures, 'module', 'ping.js'))
|
||||
@@ -209,6 +216,12 @@ describe('node feature', () => {
|
||||
describe('inspector', () => {
|
||||
let child = null
|
||||
|
||||
beforeEach(function () {
|
||||
if (!features.isRunAsNodeEnabled()) {
|
||||
this.skip()
|
||||
}
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
if (child !== null) child.kill()
|
||||
})
|
||||
@@ -291,7 +304,7 @@ describe('node feature', () => {
|
||||
|
||||
describe('net.connect', () => {
|
||||
before(function () {
|
||||
if (process.platform !== 'darwin') {
|
||||
if (!features.isRunAsNodeEnabled() || process.platform !== 'darwin') {
|
||||
this.skip()
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user