Add arch/platform to os module

This commit is contained in:
isaacs 2011-04-26 20:02:54 -07:00
Родитель b1be5409bd
Коммит a7ce79124e
3 изменённых файлов: 23 добавлений и 1 удалений

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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