Skip to content

Commit d5fa112

Browse files
committed
make jsConfigMigration nullable
1 parent f9e6a5d commit d5fa112

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

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

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

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

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

2525
export async function migrate(stylesheet: Stylesheet, options: MigrateOptions) {

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ async function run() {
123123
>()
124124
for (let sheet of stylesheets) {
125125
if (!sheet.isTailwindRoot) continue
126+
if (!sheet.linkedConfigPath) continue
126127

127128
let config = await prepareConfig(sheet.linkedConfigPath, { base })
128129
configBySheet.set(sheet, config)
@@ -147,7 +148,7 @@ async function run() {
147148
}
148149
}
149150

150-
// Migrate source files, linked to config files
151+
// Migrate source files
151152
if (configBySheet.size > 0) {
152153
info('Migrating templates…')
153154
}
@@ -190,19 +191,22 @@ async function run() {
190191
stylesheets.map(async (sheet) => {
191192
try {
192193
let config = configBySheet.get(sheet)!
193-
let jsConfigMigration = jsConfigMigrationBySheet.get(sheet)!
194+
let jsConfigMigration = jsConfigMigrationBySheet.get(sheet)
194195

195196
if (!config) {
196197
for (let parent of sheet.ancestors()) {
197198
if (parent.isTailwindRoot) {
198199
config ??= configBySheet.get(parent)!
199-
jsConfigMigration ??= jsConfigMigrationBySheet.get(parent)!
200+
jsConfigMigration ??= jsConfigMigrationBySheet.get(parent)
200201
break
201202
}
202203
}
203204
}
204205

205-
await migrateStylesheet(sheet, { ...config, jsConfigMigration })
206+
await migrateStylesheet(sheet, {
207+
...config,
208+
jsConfigMigration: jsConfigMigration ?? null,
209+
})
206210
} catch (e: any) {
207211
error(`${e?.message ?? e} in ${highlight(relative(sheet.file!, base))}`, { prefix: '↳ ' })
208212
}

0 commit comments

Comments
 (0)