File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change 1
- import fs from "node:fs"
2
- import { createIfNot } from "./utils/fileUtils"
1
+ import fs from "node:fs/promises"
2
+ import { existsSync } from "node:fs"
3
+ import { createIfNot } from "./utils/fileUtils.mjs"
3
4
import path from "node:path"
4
5
async function writeSQL ( statement , saveFileAs = "" ) {
5
6
try {
6
7
const destinationFile = process . argv [ 2 ] || saveFileAs
7
8
if ( ! destinationFile ) {
8
9
throw new Error ( "Missing saveFileAs parameter" )
9
10
}
10
- createIfNot ( path . resolve ( __dirname , `./sql/${ destinationFile } ` ) )
11
+ createIfNot ( path . resolve ( `./sql/${ destinationFile } ` ) )
11
12
await fs . writeFile ( `sql/${ process . argv [ 2 ] } .sql` , statement )
12
13
} catch ( err ) {
13
14
console . log ( err )
@@ -19,9 +20,7 @@ async function readCSV(csvFileName = "") {
19
20
if ( ! fileAndTableName ) {
20
21
throw new Error ( "Missing csvFileName parameter" )
21
22
}
22
- if (
23
- ! fs . existsSync ( path . resolve ( __dirname , `./csv/${ fileAndTableName } .csv` ) )
24
- ) {
23
+ if ( ! existsSync ( path . resolve ( `./csv/${ fileAndTableName } .csv` ) ) ) {
25
24
console . log ( "file not found" )
26
25
return
27
26
}
File renamed without changes.
You can’t perform that action at this time.
0 commit comments