From a7ce79124e6f992fa96f2dd60b8d984700e3448c Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 26 Apr 2011 20:02:54 -0700 Subject: [PATCH] Add arch/platform to os module --- doc/api/os.markdown | 8 ++++++++ lib/os.js | 6 ++++++ test/simple/test-os.js | 10 +++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/doc/api/os.markdown b/doc/api/os.markdown index d5e4a7c4e8..d867047ae9 100644 --- a/doc/api/os.markdown +++ b/doc/api/os.markdown @@ -10,6 +10,14 @@ Returns the hostname of the operating system. Returns the operating system name. +### os.platform() + +Returns the operating system platform. + +### os.arch() + +Returns the operating system CPU architecture. + ### os.release() Returns the operating system release. diff --git a/lib/os.js b/lib/os.js index e1535bcb8b..b9b04ec869 100644 --- a/lib/os.js +++ b/lib/os.js @@ -30,3 +30,9 @@ exports.cpus = binding.getCPUs; exports.type = binding.getOSType; exports.release = binding.getOSRelease; exports.getNetworkInterfaces = binding.getInterfaceAddresses; +exports.arch = function() { + return process.arch; +}; +exports.platform = function() { + return process.platform; +}; diff --git a/test/simple/test-os.js b/test/simple/test-os.js index f4641ae1cd..e4f238e4c7 100644 --- a/test/simple/test-os.js +++ b/test/simple/test-os.js @@ -44,6 +44,14 @@ var release = os.release(); console.log("release = ", release); assert.ok(release.length > 0); +var platform = os.platform(); +console.log("platform = ", platform); +assert.ok(platform.length > 0); + +var arch = os.arch(); +console.log("arch = ", arch); +assert.ok(arch.length > 0); + if (process.platform != 'sunos') { // not implemeneted yet assert.ok(os.loadavg().length > 0); @@ -54,7 +62,7 @@ if (process.platform != 'sunos') { var interfaces = os.getNetworkInterfaces(); console.error(interfaces); -switch (process.platform) { +switch (platform) { case 'linux': assert.equal('127.0.0.1', interfaces.lo.ip); break;