You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.1 KiB
32 lines
1.1 KiB
"use strict";
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.getPathToGlobalPackages = void 0;
|
|
const execa_1 = require("execa");
|
|
const path_1 = __importDefault(require("path"));
|
|
const webpack_cli_1 = require("webpack-cli");
|
|
const { getPackageManager } = webpack_cli_1.utils;
|
|
/**
|
|
*
|
|
* Returns the path to globally installed
|
|
* npm packages, depending on the available
|
|
* package manager determined by `getPackageManager`
|
|
*
|
|
* @returns {String} path - Path to global node_modules folder
|
|
*/
|
|
function getPathToGlobalPackages() {
|
|
const manager = getPackageManager();
|
|
if (manager === 'yarn') {
|
|
try {
|
|
const yarnDir = execa_1.sync('yarn', ['global', 'dir']).stdout;
|
|
return path_1.default.join(yarnDir, 'node_modules');
|
|
}
|
|
catch (e) {
|
|
// Default to the global npm path below
|
|
}
|
|
}
|
|
return require('global-modules');
|
|
}
|
|
exports.getPathToGlobalPackages = getPathToGlobalPackages;
|
|
|