how to detect MacOS Sierra version in plain javascript

80 Views Asked by At

I need to detect MacOS Sierra and its version number using plain javascript. Please help me out with a code snippet.

1

There are 1 best solutions below

0
On

try running child process with your command as below:

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}`);
});