1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const fs = require("fs");
|
4 | const lodash_1 = require("lodash");
|
5 | const path_1 = require("path");
|
6 | function getBin(pkg, binName) {
|
7 | const pJsonPath = require.resolve(`${pkg}/package.json`);
|
8 | const pJson = JSON.parse(fs.readFileSync(pJsonPath, 'utf8'));
|
9 | if (!lodash_1.has(pJson, ['bin', binName])) {
|
10 | throw new Error(`${pkg} does not have the bin ${binName}`);
|
11 | }
|
12 | return path_1.join(path_1.dirname(pJsonPath), pJson.bin[binName]);
|
13 | }
|
14 | exports.getBin = getBin;
|