2016-01-29 03:37:54 +00:00
|
|
|
import os from 'os';
|
|
|
|
|
|
|
|
function inferPlatform() {
|
2017-04-29 14:52:12 +00:00
|
|
|
const platform = os.platform();
|
|
|
|
if (platform === 'darwin' || platform === 'win32' || platform === 'linux') {
|
|
|
|
return platform;
|
|
|
|
}
|
2016-01-29 03:37:54 +00:00
|
|
|
|
2017-04-29 14:52:12 +00:00
|
|
|
throw new Error(`Untested platform ${platform} detected`);
|
2016-01-29 03:37:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function inferArch() {
|
2017-04-29 14:52:12 +00:00
|
|
|
const arch = os.arch();
|
|
|
|
if (arch !== 'ia32' && arch !== 'x64') {
|
|
|
|
throw new Error(`Incompatible architecture ${arch} detected`);
|
|
|
|
}
|
|
|
|
return arch;
|
2016-01-29 03:37:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
2017-04-29 14:52:12 +00:00
|
|
|
inferPlatform,
|
|
|
|
inferArch,
|
2016-01-29 03:37:54 +00:00
|
|
|
};
|