Skip to content

Commit 7ad6336

Browse files
committed
make configFilePath also nullable
1 parent 46a3959 commit 7ad6336

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

packages/@tailwindcss-upgrade/src/codemods/css/migrate-config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ export function migrateConfig(
1111
{
1212
configFilePath,
1313
jsConfigMigration,
14-
}: { configFilePath: string; jsConfigMigration: JSConfigMigration | null },
14+
}: { configFilePath: string | null; jsConfigMigration: JSConfigMigration | null },
1515
): Plugin {
1616
function migrate() {
1717
if (!sheet.isTailwindRoot) return
18+
if (!configFilePath) return
1819

1920
let alreadyInjected = ALREADY_INJECTED.get(sheet)
2021
if (alreadyInjected && alreadyInjected.includes(configFilePath)) {

packages/@tailwindcss-upgrade/src/codemods/css/migrate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface MigrateOptions {
1818
newPrefix: string | null
1919
designSystem: DesignSystem
2020
userConfig: Config | null
21-
configFilePath: string
21+
configFilePath: string | null
2222
jsConfigMigration: JSConfigMigration | null
2323
}
2424

packages/@tailwindcss-upgrade/src/index.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,23 +156,33 @@ async function run() {
156156
stylesheets.map(async (sheet) => {
157157
try {
158158
let config = configBySheet.get(sheet)
159-
let jsConfigMigration = jsConfigMigrationBySheet.get(sheet)
159+
let jsConfigMigration = jsConfigMigrationBySheet.get(sheet) ?? null
160160

161161
if (!config) {
162162
for (let parent of sheet.ancestors()) {
163163
if (parent.isTailwindRoot) {
164164
config ??= configBySheet.get(parent)!
165-
jsConfigMigration ??= jsConfigMigrationBySheet.get(parent)
165+
jsConfigMigration ??= jsConfigMigrationBySheet.get(parent) ?? null
166166
break
167167
}
168168
}
169169
}
170170

171-
if (!config) return
171+
let designSystem = config?.designSystem ?? (await sheet.designSystem())
172+
if (!designSystem) {
173+
return
174+
}
175+
176+
let newPrefix = config?.newPrefix ?? null
177+
let userConfig = config?.userConfig ?? null
178+
let configFilePath = config?.configFilePath ?? null
172179

173180
await migrateStylesheet(sheet, {
174-
...config,
175-
jsConfigMigration: jsConfigMigration ?? null,
181+
newPrefix,
182+
designSystem,
183+
userConfig,
184+
configFilePath,
185+
jsConfigMigration,
176186
})
177187
} catch (e: any) {
178188
error(`${e?.message ?? e} in ${highlight(relative(sheet.file!, base))}`, { prefix: '↳ ' })

0 commit comments

Comments
 (0)