//This script runs the appropriate script to check the installed react-native package's version based on the OS

var exec = require('child_process').exec;
var execFile = require('child_process').execFile;
var os  = require('os');

const puts = function (error, stdout, stderr) { 
    console.log('stdout: ' + stdout);
    console.log('stderr: ' + stderr);
    if (error !== null) {
        console.log('exec error: ' + error);
        throw "Installation failed";
    }
};

console.log("OS Detected: ");
switch(os.type()) {
    case "Darwin":
        console.log("MacOS");
        exec("chmod +x scripts/check-rn-version.sh && ./scripts/check-rn-version.sh", puts);
        break;
    case "Windows_NT":
        console.log("Windows");
        execFile("scripts\\check-rn-version-win.cmd", puts);
        break;
    case "Linux":
    default:
        console.log("Platform not supported");
}
