feat: provide package info instead of just ident

useful for reading other properties out of the package.json file
This commit is contained in:
2019-04-05 15:46:10 -07:00
parent 9fb86bf32e
commit 4cd6e2922c
2 changed files with 11 additions and 6 deletions

View File

@@ -36,7 +36,9 @@ function buildConfig(args) {
// parse args from CLI // parse args from CLI
const args = parseArgs(); const args = parseArgs();
pkgcomp(buildConfig(args), utils.getIdent(), args).catch(err => { const { name } = utils.getPackageInfo();
pkgcomp(buildConfig(args), name, args).catch(err => {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.error(err); console.error(err);
process.exit(err.exitCode); process.exit(err.exitCode);

View File

@@ -27,12 +27,15 @@ exports.getFileContents = (filePath, opts = {}) => {
return content; return content;
}; };
exports.getIdent = () => { exports.getPackageInfo = () => {
const { name } = exports.getFileContents(path.join(exports.getRootPath(), 'package.json'), { const { name, workspaces } = exports.getFileContents(
format: 'json', path.join(exports.getRootPath(), 'package.json'),
}); {
format: 'json',
}
);
if (!name) throw new Error('Unable to read project name from package.json'); if (!name) throw new Error('Unable to read project name from package.json');
return name; return { name, workspaces };
}; };
exports.getConfig = (overrides = {}) => { exports.getConfig = (overrides = {}) => {