UNPKG

@zowe/imperative

Version:
65 lines 2.94 kB
"use strict"; /* * This program and the accompanying materials are made available under the terms of the * Eclipse Public License v2.0 which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-v20.html * * SPDX-License-Identifier: EPL-2.0 * * Copyright Contributors to the Zowe Project. * */ Object.defineProperty(exports, "__esModule", { value: true }); exports.PMFConstants = void 0; const utilities_1 = require("../../../../utilities"); const path_1 = require("path"); const EnvironmentalVariableSettings_1 = require("../../env/EnvironmentalVariableSettings"); /** * Constants used by the PMF. */ class PMFConstants { /** * Get the singleton PMFConstants object. The first time this is requested, a * new object is created. * * @returns {PMFConstants} The constants class */ static get instance() { if (PMFConstants.mInstance == null) { PMFConstants.mInstance = new PMFConstants(); } return PMFConstants.mInstance; } constructor() { var _a; this.PLUGIN_CONFIG = utilities_1.ImperativeConfig.instance.config; this.NPM_NAMESPACE = "@zowe"; this.CLI_CORE_PKG_NAME = utilities_1.ImperativeConfig.instance.hostPackageName; this.IMPERATIVE_PKG_NAME = utilities_1.ImperativeConfig.instance.imperativePackageName; const envPluginsDir = EnvironmentalVariableSettings_1.EnvironmentalVariableSettings.read(utilities_1.ImperativeConfig.instance.envVariablePrefix).pluginsDir.value; this.PMF_ROOT = envPluginsDir || (0, path_1.join)(utilities_1.ImperativeConfig.instance.cliHome, "plugins"); this.PLUGIN_JSON = (0, path_1.join)(this.PMF_ROOT, "plugins.json"); this.PLUGIN_USING_CONFIG = (_a = utilities_1.ImperativeConfig.instance.config) === null || _a === void 0 ? void 0 : _a.exists; this.PLUGIN_INSTALL_LOCATION = (0, path_1.join)(this.PMF_ROOT, "installed"); // Windows format is <prefix>/node_modules if (process.platform === "win32") { this.PLUGIN_HOME_LOCATION = (0, path_1.join)(this.PLUGIN_INSTALL_LOCATION, "node_modules"); } // Everyone else is <prefix>/lib/node_modules else { this.PLUGIN_HOME_LOCATION = (0, path_1.join)(this.PLUGIN_INSTALL_LOCATION, "lib", "node_modules"); } // Build the paths to find the modules based on the config const modPaths = []; if (this.PLUGIN_USING_CONFIG) { this.PLUGIN_CONFIG.paths.forEach((path) => { const dir = (0, path_1.dirname)(path); modPaths.push((0, path_1.join)(dir, process.platform !== "win32" ? "lib" : "", "node_modules")); }); } modPaths.push(this.PLUGIN_HOME_LOCATION); this.PLUGIN_NODE_MODULE_LOCATION = Array.from(new Set(modPaths)); } } exports.PMFConstants = PMFConstants; //# sourceMappingURL=PMFConstants.js.map