kui-shell
Version:
This is the monorepo for Kui, the hybrid command-line/GUI electron-based Kubernetes tool
40 lines • 1.84 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const os_1 = require("os");
const path_1 = require("path");
exports.default = () => __awaiter(void 0, void 0, void 0, function* () {
const which = yield Promise.resolve().then(() => require('which'));
return new Promise(resolve => {
const resolveWith = (npm) => {
const npmpath = path_1.dirname(npm);
const env = Object.assign({}, process.env);
env.PATH = `${npmpath}${path_1.delimiter}${process.env.PATH}`;
resolve({ npm, env });
};
which('npm', (err, resolved) => {
if (resolved) {
resolveWith(resolved);
return;
}
if (err) {
const path = os_1.platform() === 'win32' ? `C:\\Program Files\\nodejs` : '/usr/local/bin';
resolved = which.sync('npm', { path, nothrow: true });
if (resolved) {
resolveWith(resolved);
return;
}
resolve();
}
});
});
});
//# sourceMappingURL=locate-npm.js.map