Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ program
.description('upgrade dependencies and devDependencies of all packages')
.option('--dry-run', 'no actual upgrading (just the fetching process)', false)
.option('--registry <url>', 'npm registry to use')
.action(async (targetPath: string, { dryRun, registry }) => {
.option('-m, --match <regex>', 'upgrade only packages matching the given JS Regexp')
.action(async (targetPath: string, { dryRun, registry, match }) => {
const { upgrade } = await import('./commands/upgrade.js');
const _match = typeof match === 'string' ? new RegExp(match) : undefined;

await upgrade({
directoryPath: path.resolve(targetPath || ''),
dryRun,
registryUrl: registry,
match: _match,
});
});

Expand Down
3 changes: 3 additions & 0 deletions src/commands/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface UpgradeOptions {
directoryPath: string;
dryRun?: boolean;
registryUrl?: string;
match?: RegExp;
log?: (message: unknown) => void;
logError?: (message: unknown) => void;
}
Expand All @@ -23,6 +24,7 @@ export async function upgrade({
directoryPath,
registryUrl,
dryRun,
match,
log = console.log,
logError = console.error,
}: UpgradeOptions): Promise<void> {
Expand All @@ -46,6 +48,7 @@ export async function upgrade({
!isFileColonRequest(packageVersion!) &&
!(packageName === '@types/node' && isPureNumericRequest(packageVersion!)),
)
.filter(([packageName]) => !match || match.test(packageName))
.map(([packageName]) => packageName),
),
);
Expand Down
Loading