We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 303a419 commit dc4fc6dCopy full SHA for dc4fc6d
src/Support/Helpers/updateLine.imba
@@ -1,16 +1,13 @@
1
import { promises as fs } from 'fs'
2
3
def updateLine file\string, callback\function
4
- try
5
- await fs.access(file)
6
- catch
7
- return false
+ if !existsSync(file) then return false
8
9
- const contents = await fs.readFile(file, 'utf8')
+ const contents = fs.readFileSync(file, 'utf8')
10
const lines = []
11
const splitLines = contents.split('\n')
12
for index in [0...splitLines.length]
13
lines.push callback(splitLines[index], index)
14
15
- await fs.writeFile(file, lines.join('\n'), { encoding: 'utf8' })
+ fs.writeFileSync(file, lines.join('\n'), { encoding: 'utf8' })
16
return true
0 commit comments