cli: add baseVersion option to new command
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -218,6 +218,10 @@ export function registerCommands(program: Command) {
|
||||
'--npm-registry <URL>',
|
||||
'The package registry to use for new packages',
|
||||
)
|
||||
.option(
|
||||
'--baseVersion <version>',
|
||||
'The version to use for any new packages (default: 0.1.0)',
|
||||
)
|
||||
.option('--no-private', 'Do not mark new packages as private')
|
||||
.action(lazy(() => import('./new/new').then(m => m.default)));
|
||||
|
||||
|
||||
@@ -51,17 +51,15 @@ export default async (opts: OptionValues) => {
|
||||
);
|
||||
|
||||
let defaultVersion = '0.1.0';
|
||||
try {
|
||||
const rootLernaJson = await fs.readJson(
|
||||
paths.resolveTargetRoot('lerna.json'),
|
||||
);
|
||||
if (rootLernaJson.version) {
|
||||
defaultVersion = rootLernaJson.version;
|
||||
}
|
||||
} catch (error) {
|
||||
assertError(error);
|
||||
if (error.code !== 'ENOENT') {
|
||||
throw error;
|
||||
if (opts.baseVersion) {
|
||||
defaultVersion = opts.baseVersion;
|
||||
} else {
|
||||
const lernaVersion = await fs
|
||||
.readJson(paths.resolveTargetRoot('lerna.json'))
|
||||
.then(pkg => pkg.version)
|
||||
.catch(() => undefined);
|
||||
if (lernaVersion) {
|
||||
defaultVersion = lernaVersion;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user