Skip to content

Commit

Permalink
fix(cli): use inferred project root when creating migrations from sub…
Browse files Browse the repository at this point in the history
…directory (#5905)
  • Loading branch information
juice49 committed Mar 13, 2024
1 parent 11d15ce commit 1d2775c
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ const createMigrationCommand: CliCommandDefinition<CreateMigrationFlags> = {
.replace(/\s+/g, '-')
.replace(/[^a-z0-9-]/g, '')

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

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

await writeFile(path.join(workDir, definitionFile), renderedTemplate)
await writeFile(definitionFile, renderedTemplate)
// To dry run it, run \`sanity migration run ${sluggedName}\``)
output.print()
output.print(`${chalk.green('✓')} Migration created!`)
output.print()
output.print('Next steps:')
output.print(
`Open ./${chalk.bold(
`Open ${chalk.bold(
definitionFile,
)} in your code editor and write the code for your migration.`,
)
Expand Down

0 comments on commit 1d2775c

Please sign in to comment.