Skip to content

Commit 4987cc8

Browse files
authored
fix(codemod): npm migrate issue (#140)
* fix(codemod): npm migrate issue * fix(codemod): npm migrate issue
1 parent a736537 commit 4987cc8

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

packages/codemod/src/actions/migrate-action.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type {Codemods} from '../types';
22

33
import * as p from '@clack/prompts';
4+
import {LOCKS} from '@helpers/detect';
45
import {exec} from '@helpers/exec';
56
import {Logger} from '@helpers/logger';
67
import chalk from 'chalk';
@@ -38,6 +39,7 @@ export async function migrateAction(projectPaths?: string[], options = {} as Mig
3839
const dotFiles = await findFiles(transformedPaths, {dot: true});
3940
const extraFiles = dotFiles.filter((file) => EXTRA_FILES.some((extra) => file.includes(extra)));
4041
const files = [...baseFiles, ...extraFiles];
42+
const {cmd, packageManager} = await getInstallCommand();
4143

4244
// Store the raw content of the files
4345
storePathsRawContent(files);
@@ -133,7 +135,8 @@ export async function migrateAction(projectPaths?: string[], options = {} as Mig
133135
/** ======================== 6. Migrate npmrc optional (Pnpm only) ======================== */
134136
const runMigrateNpmrc = getCanRunCodemod(codemod, 'npmrc');
135137

136-
if (runMigrateNpmrc) {
138+
// Pnpm only
139+
if (runMigrateNpmrc && packageManager === 'pnpm') {
137140
const npmrcFiles = dotFiles.filter((path) => path.includes('.npmrc'));
138141

139142
p.log.step(`${step}. Migrating "npmrc" (Pnpm only)`);
@@ -152,7 +155,7 @@ export async function migrateAction(projectPaths?: string[], options = {} as Mig
152155
const remainingFiles = [
153156
...nextuiFiles.filter((file) => !affectedFiles.has(file)),
154157
...remainingNextuiFiles
155-
];
158+
].filter((file) => !Object.keys(LOCKS).some((lock) => file.includes(lock))); // Should ignore lock files
156159
const runCheckLeftFiles = remainingFiles.length > 0;
157160

158161
// If user not using individual codemod, we need to ask user to replace left files
@@ -204,8 +207,6 @@ export async function migrateAction(projectPaths?: string[], options = {} as Mig
204207
});
205208

206209
if (selectReinstallDependencies) {
207-
const {cmd} = await getInstallCommand();
208-
209210
try {
210211
await exec(cmd);
211212
} catch {

packages/codemod/src/helpers/lint.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export async function lintWithESLint(filePaths: string[]) {
2020
const result = await eslint.lintFiles(filePaths);
2121

2222
await ESLint.outputFixes(result);
23+
24+
return result;
2325
}
2426
}
2527

0 commit comments

Comments
 (0)