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
|
// 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);
|
||||||
|
|||||||
13
src/utils.js
13
src/utils.js
@@ -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 = {}) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user