File tree Expand file tree Collapse file tree 4 files changed +27
-4
lines changed
Expand file tree Collapse file tree 4 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -452,6 +452,21 @@ On POSIX systems, the operating system release is determined by calling
452452available, ` GetVersionExW() ` will be used. See
453453< https://en.wikipedia.org/wiki/Uname#Examples > for more information.
454454
455+ ## ` os.machine() `
456+
457+ <!-- YAML
458+ added: REPLACEME
459+ -->
460+
461+ * Returns {string}
462+
463+ Returns the machine type as a string, such as ` x86_64 ` .
464+
465+ On POSIX systems, the machine type is determined by calling
466+ [ ` uname(3) ` ] [ ] . On Windows, ` RtlGetVersion() ` is used, and if it is not
467+ available, ` GetVersionExW() ` will be used. See
468+ < https://en.wikipedia.org/wiki/Uname#Examples > for more information.
469+
455470## OS constants
456471
457472The following constants are exported by ` os.constants ` .
Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ const {
7575 0 : type ,
7676 1 : version ,
7777 2 : release ,
78+ 3 : machine ,
7879} = _getOSInformation ( ) ;
7980
8081const getHomeDirectory = getCheckedFunction ( _getHomeDirectory ) ;
@@ -92,12 +93,17 @@ const getOSType = () => type;
9293 * @returns {string }
9394 */
9495const getOSVersion = ( ) => version ;
96+ /**
97+ * @returns {string }
98+ */
99+ const getMachine = ( ) => machine ;
95100
96101getFreeMem [ SymbolToPrimitive ] = ( ) => getFreeMem ( ) ;
97102getHostname [ SymbolToPrimitive ] = ( ) => getHostname ( ) ;
98103getOSVersion [ SymbolToPrimitive ] = ( ) => getOSVersion ( ) ;
99104getOSType [ SymbolToPrimitive ] = ( ) => getOSType ( ) ;
100105getOSRelease [ SymbolToPrimitive ] = ( ) => getOSRelease ( ) ;
106+ getMachine [ SymbolToPrimitive ] = ( ) => getMachine ( ) ;
101107getHomeDirectory [ SymbolToPrimitive ] = ( ) => getHomeDirectory ( ) ;
102108getTotalMem [ SymbolToPrimitive ] = ( ) => getTotalMem ( ) ;
103109getUptime [ SymbolToPrimitive ] = ( ) => getUptime ( ) ;
@@ -367,7 +373,8 @@ module.exports = {
367373 type : getOSType ,
368374 userInfo,
369375 uptime : getUptime ,
370- version : getOSVersion
376+ version : getOSVersion ,
377+ machine : getMachine ,
371378} ;
372379
373380ObjectDefineProperties ( module . exports , {
Original file line number Diff line number Diff line change @@ -86,11 +86,12 @@ static void GetOSInformation(const FunctionCallbackInfo<Value>& args) {
8686 return args.GetReturnValue ().SetUndefined ();
8787 }
8888
89- // [sysname, version, release]
89+ // [sysname, version, release, machine ]
9090 Local<Value> osInformation[] = {
9191 String::NewFromUtf8 (env->isolate (), info.sysname ).ToLocalChecked (),
9292 String::NewFromUtf8 (env->isolate (), info.version ).ToLocalChecked (),
93- String::NewFromUtf8 (env->isolate (), info.release ).ToLocalChecked ()
93+ String::NewFromUtf8 (env->isolate (), info.release ).ToLocalChecked (),
94+ String::NewFromUtf8 (env->isolate (), info.machine ).ToLocalChecked ()
9495 };
9596
9697 args.GetReturnValue ().Set (Array::New (env->isolate (),
Original file line number Diff line number Diff line change @@ -245,7 +245,7 @@ assert.strictEqual(`${os.tmpdir}`, os.tmpdir());
245245assert . strictEqual ( `${ os . arch } ` , os . arch ( ) ) ;
246246assert . strictEqual ( `${ os . platform } ` , os . platform ( ) ) ;
247247assert . strictEqual ( `${ os . version } ` , os . version ( ) ) ;
248-
248+ assert . strictEqual ( ` ${ os . machine } ` , os . machine ( ) ) ;
249249assert . strictEqual ( + os . totalmem , os . totalmem ( ) ) ;
250250
251251// Assert that the following values are coercible to numbers.
You can’t perform that action at this time.
0 commit comments