From 2b5f139cea281aa9752ccc0898ddf7664a87ce9a Mon Sep 17 00:00:00 2001 From: Tomas Reimers Date: Thu, 3 Sep 2020 03:50:37 -0400 Subject: [PATCH] feat: support absolute paths in migrationsDir for the CLI (#6660) Right now the CLI will ALWAYS prepend the CWD to `options.cli.migrationsDir`. This prevents us from using absolute paths there. How would we feel about changing that to support absolute paths (by only prepending CLI if the path DOES NOT start with "/")? If we're open to it, I'm happy to make the change for the other CLI commands as well. --- src/commands/MigrationCreateCommand.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/MigrationCreateCommand.ts b/src/commands/MigrationCreateCommand.ts index 9d39b06174..383e30c680 100644 --- a/src/commands/MigrationCreateCommand.ts +++ b/src/commands/MigrationCreateCommand.ts @@ -59,7 +59,7 @@ export class MigrationCreateCommand implements yargs.CommandModule { } catch (err) { } } - const path = process.cwd() + "/" + (directory ? (directory + "/") : "") + filename; + const path = (directory.startsWith("/") ? "" : process.cwd() + "/") + (directory ? (directory + "/") : "") + filename; await CommandUtils.createFile(path, fileContent); console.log(`Migration ${chalk.blue(path)} has been generated successfully.`);