Skip to content

Commit 18fd3ed

Browse files
committed
chore: optimize raw commands readability
1 parent b656805 commit 18fd3ed

File tree

2 files changed

+31
-18
lines changed

2 files changed

+31
-18
lines changed

packages/cli/src/actions/db.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@ async function runPush(options: Options) {
2626

2727
try {
2828
// run prisma db push
29-
const cmd = `prisma db push --schema "${prismaSchemaFile}"${
30-
options.acceptDataLoss ? ' --accept-data-loss' : ''
31-
}${options.forceReset ? ' --force-reset' : ''} --skip-generate`;
29+
const cmd = [
30+
'prisma db push',
31+
` --schema "${prismaSchemaFile}"`,
32+
options.acceptDataLoss && ' --accept-data-loss',
33+
options.forceReset && ' --force-reset',
34+
' --skip-generate',
35+
].join('');
36+
3237
try {
33-
await execPackage(cmd, {
34-
stdio: 'inherit',
35-
});
38+
await execPackage(cmd);
3639
} catch (err) {
3740
handleSubProcessError(err);
3841
}

packages/cli/src/actions/migrate.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,32 +53,42 @@ export async function run(command: string, options: CommonOptions) {
5353

5454
async function runDev(prismaSchemaFile: string, options: DevOptions) {
5555
try {
56-
await execPackage(
57-
`prisma migrate dev --schema "${prismaSchemaFile}" --skip-generate${options.name ? ` --name ${options.name}` : ''}${options.createOnly ? ' --create-only' : ''}`,
58-
{
59-
stdio: 'inherit',
60-
},
61-
);
56+
const cmd = [
57+
'prisma migrate dev',
58+
` --schema "${prismaSchemaFile}"`,
59+
' --skip-generate',
60+
options.name && ` --name ${options.name}`,
61+
options.createOnly && ' --create-only',
62+
].join('');
63+
64+
await execPackage(cmd);
6265
} catch (err) {
6366
handleSubProcessError(err);
6467
}
6568
}
6669

6770
async function runReset(prismaSchemaFile: string, options: ResetOptions) {
6871
try {
69-
await execPackage(`prisma migrate reset --schema "${prismaSchemaFile}"${options.force ? ' --force' : ''}`, {
70-
stdio: 'inherit',
71-
});
72+
const cmd = [
73+
'prisma migrate reset',
74+
` --schema "${prismaSchemaFile}"`,
75+
options.force && ' --force',
76+
].join('');
77+
78+
await execPackage(cmd);
7279
} catch (err) {
7380
handleSubProcessError(err);
7481
}
7582
}
7683

7784
async function runDeploy(prismaSchemaFile: string, _options: DeployOptions) {
7885
try {
79-
await execPackage(`prisma migrate deploy --schema "${prismaSchemaFile}"`, {
80-
stdio: 'inherit',
81-
});
86+
const cmd = [
87+
'prisma migrate deploy',
88+
` --schema "${prismaSchemaFile}"`,
89+
].join('');
90+
91+
await execPackage(cmd);
8292
} catch (err) {
8393
handleSubProcessError(err);
8494
}

0 commit comments

Comments
 (0)