Skip to content

Commit a7ce791

Browse files
committed
Add arch/platform to os module
1 parent b1be540 commit a7ce791

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

doc/api/os.markdown

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ Returns the hostname of the operating system.
1010

1111
Returns the operating system name.
1212

13+
### os.platform()
14+
15+
Returns the operating system platform.
16+
17+
### os.arch()
18+
19+
Returns the operating system CPU architecture.
20+
1321
### os.release()
1422

1523
Returns the operating system release.

lib/os.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,9 @@ exports.cpus = binding.getCPUs;
3030
exports.type = binding.getOSType;
3131
exports.release = binding.getOSRelease;
3232
exports.getNetworkInterfaces = binding.getInterfaceAddresses;
33+
exports.arch = function() {
34+
return process.arch;
35+
};
36+
exports.platform = function() {
37+
return process.platform;
38+
};

test/simple/test-os.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ var release = os.release();
4444
console.log("release = ", release);
4545
assert.ok(release.length > 0);
4646

47+
var platform = os.platform();
48+
console.log("platform = ", platform);
49+
assert.ok(platform.length > 0);
50+
51+
var arch = os.arch();
52+
console.log("arch = ", arch);
53+
assert.ok(arch.length > 0);
54+
4755
if (process.platform != 'sunos') {
4856
// not implemeneted yet
4957
assert.ok(os.loadavg().length > 0);
@@ -54,7 +62,7 @@ if (process.platform != 'sunos') {
5462

5563
var interfaces = os.getNetworkInterfaces();
5664
console.error(interfaces);
57-
switch (process.platform) {
65+
switch (platform) {
5866
case 'linux':
5967
assert.equal('127.0.0.1', interfaces.lo.ip);
6068
break;

0 commit comments

Comments
 (0)