feat: provide package info instead of just ident
useful for reading other properties out of the package.json file
This commit is contained in:
@@ -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);
|
||||
|
||||
13
src/utils.js
13
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 = {}) => {
|
||||
|
||||
Reference in New Issue
Block a user