Skip to content

Commit 96aca67

Browse files
committed
solving error
1 parent 2170fed commit 96aca67

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

index.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
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"
34
import path from "node:path"
45
async function writeSQL(statement, saveFileAs = "") {
56
try {
67
const destinationFile = process.argv[2] || saveFileAs
78
if (!destinationFile) {
89
throw new Error("Missing saveFileAs parameter")
910
}
10-
createIfNot(path.resolve(__dirname, `./sql/${destinationFile}`))
11+
createIfNot(path.resolve(`./sql/${destinationFile}`))
1112
await fs.writeFile(`sql/${process.argv[2]}.sql`, statement)
1213
} catch (err) {
1314
console.log(err)
@@ -19,9 +20,7 @@ async function readCSV(csvFileName = "") {
1920
if (!fileAndTableName) {
2021
throw new Error("Missing csvFileName parameter")
2122
}
22-
if (
23-
!fs.existsSync(path.resolve(__dirname, `./csv/${fileAndTableName}.csv`))
24-
) {
23+
if (!existsSync(path.resolve(`./csv/${fileAndTableName}.csv`))) {
2524
console.log("file not found")
2625
return
2726
}
File renamed without changes.

0 commit comments

Comments
 (0)