Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js to get/determine OS version

I'd like to determine whether some script that is being executed is running a particular version of Mac OSX. I realize I can exec/spawn the command:

sw_vers -productVersion

Is there a way to do this synchronously (similar to process.arch) without node-exec-sync? I realize its an accepted bad practice to spawn/exec synchronously, but I don't see another way.

like image 467
badunk Avatar asked Feb 20 '13 20:02

badunk


1 Answers

you could use the OS module like this:

var os = require('os');
os.platform(); // 'darwin'
os.release(); //'10.8.0'

and then map the release version to a specific version of Mac OS X.

Darwin to Mac OS X mappings can be found here

like image 165
AndyD Avatar answered Oct 01 '22 08:10

AndyD