File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
packages/velog-prisma/scripts Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -57,8 +57,7 @@ function getMessage(migrationDiff: string[]): string {
57
57
const question = `🤔 Are you sure?`
58
58
return [
59
59
title ,
60
- ...migrationDiff . map ( ( filename ) => ` - ${ filename } \n\n${ getMigrationSummary ( filename ) } ` ) ,
61
- '' ,
60
+ ...migrationDiff . map ( ( filename ) => ` - ${ filename } \n${ getMigrationSummary ( filename ) } ` ) ,
62
61
question ,
63
62
] . join ( '\n' )
64
63
}
@@ -72,10 +71,12 @@ function getMigrationSummary(filename: string) {
72
71
)
73
72
74
73
const sql = fs . readFileSync ( filepath , { encoding : 'utf-8' } )
74
+ const lines = sql . split ( '\n' )
75
+
75
76
const target = [ 'ALTER' , 'CREATE' , 'DROP' ]
76
- return sql
77
- . split ( '\n' )
77
+ return lines
78
78
. filter ( ( line ) => target . some ( ( str ) => line . includes ( str ) ) )
79
79
. map ( ( v ) => ` - ${ v . replace ( / [ { } \[ \] ( ) < > ; ] + / g, '' ) . toLowerCase ( ) } ` )
80
+ . map ( ( v , i , arr ) => ( i === arr . length - 1 ? `${ v } \n` : v ) )
80
81
. join ( '\n' )
81
82
}
You can’t perform that action at this time.
0 commit comments