feat: added process.electron to get the electron version in forked process (#16450)

This commit is contained in:
SamvelRaja 2019-01-30 11:43:18 +05:30 committed by Shelley Vohr
parent 8da91523d0
commit 8af532ba98
2 changed files with 18 additions and 0 deletions

View file

@ -11,6 +11,7 @@
#include "atom/browser/javascript_environment.h"
#include "atom/browser/node_debugger.h"
#include "atom/common/api/atom_bindings.h"
#include "atom/common/atom_version.h"
#include "atom/common/crash_reporter/crash_reporter.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/node_bindings.h"
@ -79,6 +80,11 @@ int NodeMain(int argc, char* argv[]) {
reporter.SetMethod("start", &crash_reporter::CrashReporter::StartInstance);
process.Set("crashReporter", reporter);
mate::Dictionary versions;
if (process.Get("versions", &versions)) {
versions.SetReadOnly(ATOM_PROJECT_NAME, ATOM_VERSION_STRING);
}
node::LoadEnvironment(env);
bool more;

View file

@ -111,6 +111,18 @@ describe('node feature', () => {
})
forked.send('hello')
})
it('has the electron version in process.versions', (done) => {
const source = 'process.send(process.versions)'
const forked = ChildProcess.fork('--eval', [source])
forked.on('message', (message) => {
expect(message)
.to.have.own.property('electron')
.that.is.a('string')
.and.matches(/^\d+\.\d+\.\d+(\S*)?$/)
done()
})
})
})
describe('child_process.spawn', () => {