Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
632 views
Welcome To Ask or Share your Answers For Others

1 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...