Skip to content

Commit 1d2775c

Browse files
authoredMar 13, 2024
fix(cli): use inferred project root when creating migrations from subdirectory (#5905)
1 parent 11d15ce commit 1d2775c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎packages/sanity/src/_internal/cli/commands/migration/createMigrationCommand.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ const createMigrationCommand: CliCommandDefinition<CreateMigrationFlags> = {
7676
.replace(/\s+/g, '-')
7777
.replace(/[^a-z0-9-]/g, '')
7878

79-
const destDir = path.join(MIGRATIONS_DIRECTORY, sluggedName)
79+
const destDir = path.join(workDir, MIGRATIONS_DIRECTORY, sluggedName)
8080
if (existsSync(destDir)) {
8181
if (
8282
!(await prompt.single({
8383
type: 'confirm',
84-
message: `Migration directory ./${destDir} already exists. Overwrite?`,
84+
message: `Migration directory ${chalk.cyan(destDir)} already exists. Overwrite?`,
8585
default: false,
8686
}))
8787
) {
@@ -100,14 +100,14 @@ const createMigrationCommand: CliCommandDefinition<CreateMigrationFlags> = {
100100

101101
const definitionFile = path.join(destDir, 'index.ts')
102102

103-
await writeFile(path.join(workDir, definitionFile), renderedTemplate)
103+
await writeFile(definitionFile, renderedTemplate)
104104
// To dry run it, run \`sanity migration run ${sluggedName}\``)
105105
output.print()
106106
output.print(`${chalk.green('✓')} Migration created!`)
107107
output.print()
108108
output.print('Next steps:')
109109
output.print(
110-
`Open ./${chalk.bold(
110+
`Open ${chalk.bold(
111111
definitionFile,
112112
)} in your code editor and write the code for your migration.`,
113113
)

0 commit comments

Comments
 (0)
Please sign in to comment.