Browse Source

Add arch/platform to os module

v0.7.4-release
isaacs 14 years ago
parent
commit
a7ce79124e
  1. 8
      doc/api/os.markdown
  2. 6
      lib/os.js
  3. 10
      test/simple/test-os.js

8
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.

6
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;
};

10
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;

Loading…
Cancel
Save