Skip to content

Commit 54b70a7

Browse files
committed
Use optional catch bindings
1 parent 3045387 commit 54b70a7

File tree

10 files changed

+16
-17
lines changed

10 files changed

+16
-17
lines changed

lib/copy/__tests__/copy-permissions.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ describe('copy', () => {
3232

3333
try {
3434
gidWheel = process.getgid() // userid.gid('wheel')
35-
} catch (err) {
35+
} catch {
3636
gidWheel = process.getgid()
3737
}
3838

3939
try {
4040
gidStaff = process.getgid() // userid.gid('staff')
41-
} catch (err) {
41+
} catch {
4242
gidStaff = process.getgid()
4343
}
4444

lib/empty/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function emptyDirSync (dir) {
3030
let items
3131
try {
3232
items = fs.readdirSync(dir)
33-
} catch (err) {
33+
} catch {
3434
return mkdir.mkdirsSync(dir)
3535
}
3636

lib/ensure/file.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function createFileSync (file) {
4444
let stats
4545
try {
4646
stats = fs.statSync(file)
47-
} catch (e) {}
47+
} catch {}
4848
if (stats && stats.isFile()) return
4949

5050
const dir = path.dirname(file)

lib/ensure/symlink-type.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function symlinkTypeSync (srcpath, type) {
1919
if (type) return type
2020
try {
2121
stats = fs.lstatSync(srcpath)
22-
} catch (e) {
22+
} catch {
2323
return 'file'
2424
}
2525
return (stats && stats.isDirectory()) ? 'dir' : 'file'

lib/mkdirs/__tests__/issue-209.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ describe('mkdirp: issue-209, win32, when bad path, should return a cleaner error
3030
try {
3131
const file = 'c:\\tmp\foo:moo'
3232
fse.mkdirpSync(file)
33-
} catch (err) {
34-
// console.error(err)
33+
} catch {
3534
didErr = true
3635
}
3736
assert(didErr)

lib/mkdirs/mkdirs-sync.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ function mkdirsSync (p, opts, made) {
2828
try {
2929
xfs.mkdirSync(p, mode)
3030
made = made || p
31-
} catch (err0) {
32-
if (err0.code === 'ENOENT') {
33-
if (path.dirname(p) === p) throw err0
31+
} catch (err) {
32+
if (err.code === 'ENOENT') {
33+
if (path.dirname(p) === p) throw err
3434
made = mkdirsSync(path.dirname(p), opts, made)
3535
mkdirsSync(p, opts, made)
3636
} else {
@@ -39,10 +39,10 @@ function mkdirsSync (p, opts, made) {
3939
let stat
4040
try {
4141
stat = xfs.statSync(p)
42-
} catch (err1) {
43-
throw err0
42+
} catch {
43+
throw err
4444
}
45-
if (!stat.isDirectory()) throw err0
45+
if (!stat.isDirectory()) throw err
4646
}
4747
}
4848

lib/move-sync/__tests__/move-sync.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ describe('moveSync()', () => {
281281
// make sure we have permission on device
282282
try {
283283
fs.writeFileSync(path.join(differentDevice, 'file'), 'hi')
284-
} catch (err) {
284+
} catch {
285285
console.log("Can't write to device. Skipping moveSync test.")
286286
__skipTests = true
287287
}

lib/move/__tests__/move.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ describe('+ move()', () => {
324324
// make sure we have permission on device
325325
try {
326326
fs.writeFileSync(path.join(differentDevice, 'file'), 'hi')
327-
} catch (err) {
327+
} catch {
328328
console.log("Can't write to device. Skipping move test.")
329329
__skipTests = true
330330
}

lib/remove/rimraf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ function rmkidsSync (p, options) {
302302
try {
303303
const ret = options.rmdirSync(p, options)
304304
return ret
305-
} catch (er) { }
305+
} catch {}
306306
} while (Date.now() - startTime < 500) // give up after 500ms
307307
} else {
308308
const ret = options.rmdirSync(p, options)

lib/util/buffer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = function (size) {
44
if (typeof Buffer.allocUnsafe === 'function') {
55
try {
66
return Buffer.allocUnsafe(size)
7-
} catch (e) {
7+
} catch {
88
return new Buffer(size)
99
}
1010
}

0 commit comments

Comments
 (0)