我需要使用纯 javascript检测MacOS Sierra 及其版本号。请帮我提供一个代码片段。
问问题
46 次
1 回答
0
尝试使用您的命令运行子进程,如下所示:
const { exec } = require("child_process");
exec("system_profiler SPSoftwareDataType", (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
});
于 2020-06-03T02:18:54.653 回答