Node.js to get/determine OS version

前端 未结 2 818
有刺的猬
有刺的猬 2020-12-20 12:36

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_ver         


        
2条回答
  •  一个人的身影
    2020-12-20 12:47

    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

提交回复
热议问题