@fdm-monster/cli
Version:
FDM Monster CLI aids in the process of installing, updating and maintaining your FDM Monster server across windows, mac and linux.
78 lines (77 loc) • 2.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
checkArch: function() {
return checkArch;
},
detectServiceInstallerRequired: function() {
return detectServiceInstallerRequired;
},
getServiceFolder: function() {
return getServiceFolder;
},
getWorkspaceFolder: function() {
return getWorkspaceFolder;
},
serviceExists: function() {
return serviceExists;
}
});
const _path = require("path");
const _os = require("os");
function serviceExists(service, serviceType) {
return serviceType == "node-linux" ? service.exists() : service.exists;
}
function getWorkspaceFolder(cwd) {
return (0, _path.join)(cwd, "workspace");
}
function getServiceFolder(cwd, silent = true) {
const { platformOs, serviceInstaller } = detectServiceInstallerRequired(silent);
return (0, _path.join)(cwd, "platforms", platformOs);
}
function detectServiceInstallerRequired(silent = true) {
if (!silent) {
checkArch();
}
let serviceInstaller = "node-linux";
const platformOs = (0, _os.platform)();
switch(platformOs){
case "darwin":
serviceInstaller = "node-mac";
break;
case "win32":
serviceInstaller = "node-windows";
break;
case "linux":
serviceInstaller = "node-linux";
break;
default:
console.warn(`The platform ${platformOs} is not supported, the service package ${serviceInstaller}. Please proceed with caution.`);
}
if (!silent) {
console.debug(`Detected platform ${platformOs} and chose installer [${serviceInstaller}].`);
}
return {
platformOs,
serviceInstaller
};
}
function checkArch() {
const architecture = (0, _os.arch)();
if (![
"arm64",
"x64"
].includes(architecture)) {
console.warn(`FDM Monster is installed on architecture ${architecture}. This seems unsupported and you are therefore operating at your own risk.`);
}
return architecture;
}
//# sourceMappingURL=utils.js.map