UNPKG

553 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const fs = require("fs");
4const lodash_1 = require("lodash");
5const path_1 = require("path");
6function 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}
14exports.getBin = getBin;