Skip to content

Commit c8ef004

Browse files
authored
fix: linting (#111)
1 parent 71047db commit c8ef004

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/index.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ function cleanupOnExit (tmpfile) {
3939
return () => {
4040
try {
4141
fs.unlinkSync(typeof tmpfile === 'function' ? tmpfile() : tmpfile)
42-
} catch (_) {}
42+
} catch {
43+
// ignore errors
44+
}
4345
}
4446
}
4547

@@ -156,15 +158,20 @@ async function writeFileAsync (filename, data, options = {}) {
156158
}
157159
}
158160

159-
function writeFile (filename, data, options, callback) {
161+
async function writeFile (filename, data, options, callback) {
160162
if (options instanceof Function) {
161163
callback = options
162164
options = {}
163165
}
164166

165167
const promise = writeFileAsync(filename, data, options)
166168
if (callback) {
167-
promise.then(callback, callback)
169+
try {
170+
const result = await promise
171+
return callback(result)
172+
} catch (err) {
173+
return callback(err)
174+
}
168175
}
169176

170177
return promise

0 commit comments

Comments
 (0)