diff --git a/CHANGELOG.md b/CHANGELOG.md index a8a414fec022..f4ab2a1e561c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Upgrade: Do not migrate declarations that look like candidates in ` `, 'src/input.css': css` @@ -3016,21 +3166,21 @@ test( expect(await fs.dumpFiles('./src/**/*.{css,vue}')).toMatchInlineSnapshot(` " --- ./src/index.vue --- - --- ./src/input.css --- diff --git a/packages/@tailwindcss-upgrade/src/codemods/css/analyze.ts b/packages/@tailwindcss-upgrade/src/codemods/css/analyze.ts index 954d8ce0f869..c9af6a7a38cf 100644 --- a/packages/@tailwindcss-upgrade/src/codemods/css/analyze.ts +++ b/packages/@tailwindcss-upgrade/src/codemods/css/analyze.ts @@ -12,7 +12,14 @@ export async function analyze(stylesheets: Stylesheet[]) { let processingQueue: (() => Promise)[] = [] let stylesheetsByFile = new DefaultMap((file) => { // We don't want to process ignored files (like node_modules) - if (isIgnored(file)) { + try { + if (isIgnored(file)) { + return null + } + } catch { + // If the file is not part of the current working directory (which can + // happen if you import `tailwindcss` and it's loading a shared file from + // pnpm) then this will throw. return null } diff --git a/packages/@tailwindcss-upgrade/src/utils/packages.ts b/packages/@tailwindcss-upgrade/src/utils/packages.ts index 9f7f5619f005..65f823bec7e0 100644 --- a/packages/@tailwindcss-upgrade/src/utils/packages.ts +++ b/packages/@tailwindcss-upgrade/src/utils/packages.ts @@ -31,6 +31,13 @@ export function pkg(base: string) { args.push(SAVE_DEV[packageManager] || SAVE_DEV.default) } + // Allow running the `pnpm` command in the workspace root without + // erroring. Can't just use `--workspace-root` because that will force + // install dependencies in the workspace root. + if (packageManager === 'pnpm') { + args.push('--ignore-workspace-root-check') + } + let command = `${packageManager} add ${args.join(' ')}` try { return await exec(command, { cwd: base })