Skip to content

Commit

Permalink
Sanitize queried node types version
Browse files Browse the repository at this point in the history
  • Loading branch information
zbrydon committed Jan 15, 2025
1 parent 805ec17 commit 0efdaf0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/cli/migrate/nodeVersion/getNode22TypesVersion.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { execSync } from 'child_process';

export const getNode22TypesVersion = (major: number) =>
execSync(`npm show @types/node@^${major} version --json | jq '.[-1]'`)
.toString()
.replace(/"/g, '');
execSync(
`npm show @types/node@^${major} version --json | jq '.[-1]'`,
).toString();
5 changes: 3 additions & 2 deletions src/cli/migrate/nodeVersion/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ export const getNode22TypeVersion = (
): VersionResult => {
try {
const version = getNode22TypesVersion(major);
if (!version || !/22\.\d+\.\d+/.test(version)) {
const versionRegex = /(22\.\d+\.\d+)/;
if (!version || !versionRegex.test(version)) {
throw new Error('No version found');
}
return {
version,
version: version.replace(versionRegex, '$1'),
err: undefined,
};
} catch {
Expand Down

0 comments on commit 0efdaf0

Please sign in to comment.