diff --git a/atom/app/node_main.cc b/atom/app/node_main.cc index ab55b49e0751..08e39c51ee87 100644 --- a/atom/app/node_main.cc +++ b/atom/app/node_main.cc @@ -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; diff --git a/spec/node-spec.js b/spec/node-spec.js index bba325ee4895..e1316d287550 100644 --- a/spec/node-spec.js +++ b/spec/node-spec.js @@ -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', () => {