UNPKG

rollup-umd-scripts

Version:

CLI for rollup-umd projects

42 lines (37 loc) 1.27 kB
'use strict'; var _keys = require('babel-runtime/core-js/object/keys'); var _keys2 = _interopRequireDefault(_keys); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /* eslint-disable */ var path = require('path'); exports.command = ['npm-install-cmd', 'npm']; exports.desc = 'Display the npm installation command for the peers of the module'; exports.builder = function (yargs) { return yargs.option('path', { alias: 'p', describe: 'path', default: process.cwd() }); }; exports.handler = function (argv) { switch (argv.path[0]) { case '/': break; default: argv.path = argv.path[1] === '/' ? path.join(process.cwd(), argv.path.slice(2)) : path.join(process.cwd(), argv.path); break; } var pkg = void 0; try { pkg = require(path.join(argv.path, 'package.json')); } catch (e) { console.error('[ERROR] You must be in a project to read it\'s dependencies'); process.exit(1); } var peer = pkg.peerDependencies; var installList = (0, _keys2.default)(peer).map(function (key) { return peer[key].match(/^git@?\+?/gm) ? peer[key] : key + '@' + peer[key]; }); var installCmd = 'npm install --save ' + installList.join(' '); console.log(installCmd); };