@zohodesk/client_build_tool
Version:
A CLI tool to build web applications and client libraries
39 lines (30 loc) • 1.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getCliPath = getCliPath;
var _os = require("os");
var _fs = require("fs");
var _path = require("path");
var _constants = require("../constants");
const isWindows = (0, _os.platform)().toLowerCase() === 'win32';
const suffixExt = isWindows ? '.cmd' : ''; // function searchForCommandPath(commandName) {
// let pathFolders = __dirname.split(sep);
// let cliPath;
// while (pathFolders.pop()) {
// cliPath = join(pathFolders.join(sep), 'node_modules', '.bin', commandName);
// if (existsSync(cliPath)) {
// return cliPath;
// }
// }
// console.warn(`unable to find command "${commandName}"`);
// return join(__dirname, '..', 'node_modules', '.bin', commandName);
// }
function searchForCommandPath(libName) {
const commandPath = (0, _path.join)(_constants.cliNodeModulesPath, '.bin', libName); // TODO: need to check for windows machine reason command with ext added,
// when we use global react-cli package (executable) working or not
return (0, _fs.existsSync)(commandPath) ? commandPath : libName;
}
function getCliPath(commandName) {
return searchForCommandPath(commandName + suffixExt);
}