From 4cd6e2922c3d940d3c3c19e2c04f129ead67a138 Mon Sep 17 00:00:00 2001 From: joe fleming Date: Fri, 5 Apr 2019 15:46:10 -0700 Subject: [PATCH] feat: provide package info instead of just ident useful for reading other properties out of the package.json file --- src/cli.js | 4 +++- src/utils.js | 13 ++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/cli.js b/src/cli.js index 01cd8d3..a523643 100755 --- a/src/cli.js +++ b/src/cli.js @@ -36,7 +36,9 @@ function buildConfig(args) { // parse args from CLI 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 console.error(err); process.exit(err.exitCode); diff --git a/src/utils.js b/src/utils.js index 6c00229..7f98b6a 100644 --- a/src/utils.js +++ b/src/utils.js @@ -27,12 +27,15 @@ exports.getFileContents = (filePath, opts = {}) => { return content; }; -exports.getIdent = () => { - const { name } = exports.getFileContents(path.join(exports.getRootPath(), 'package.json'), { - format: 'json', - }); +exports.getPackageInfo = () => { + const { name, workspaces } = exports.getFileContents( + path.join(exports.getRootPath(), 'package.json'), + { + format: 'json', + } + ); if (!name) throw new Error('Unable to read project name from package.json'); - return name; + return { name, workspaces }; }; exports.getConfig = (overrides = {}) => {