Skip to content

Commit dc4fc6d

Browse files
committed
fix: use sync
1 parent 303a419 commit dc4fc6d

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
import { promises as fs } from 'fs'
22

33
def updateLine file\string, callback\function
4-
try
5-
await fs.access(file)
6-
catch
7-
return false
4+
if !existsSync(file) then return false
85

9-
const contents = await fs.readFile(file, 'utf8')
6+
const contents = fs.readFileSync(file, 'utf8')
107
const lines = []
118
const splitLines = contents.split('\n')
129
for index in [0...splitLines.length]
1310
lines.push callback(splitLines[index], index)
1411

15-
await fs.writeFile(file, lines.join('\n'), { encoding: 'utf8' })
12+
fs.writeFileSync(file, lines.join('\n'), { encoding: 'utf8' })
1613
return true

0 commit comments

Comments
 (0)