Skip to content

Commit 54e8845

Browse files
Trottrvagg
authored andcommitted
fs: refactor redeclared variables
Two variables are declared twice with `var` in the same scope in `lib/fs.js`. This change refactors the code so the variable is declared just once. PR-URL: #4959 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Brian White <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent d619977 commit 54e8845

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

lib/fs.js

+6-10
Original file line numberDiff line numberDiff line change
@@ -1446,18 +1446,14 @@ fs.unwatchFile = function(filename, listener) {
14461446

14471447
// Regexp that finds the next partion of a (partial) path
14481448
// result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
1449-
if (isWindows) {
1450-
var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
1451-
} else {
1452-
var nextPartRe = /(.*?)(?:[\/]+|$)/g;
1453-
}
1449+
const nextPartRe = isWindows ?
1450+
/(.*?)(?:[\/\\]+|$)/g :
1451+
/(.*?)(?:[\/]+|$)/g;
14541452

14551453
// Regex to find the device root, including trailing slash. E.g. 'c:\\'.
1456-
if (isWindows) {
1457-
var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
1458-
} else {
1459-
var splitRootRe = /^[\/]*/;
1460-
}
1454+
const splitRootRe = isWindows ?
1455+
/^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/ :
1456+
/^[\/]*/;
14611457

14621458
fs.realpathSync = function realpathSync(p, cache) {
14631459
// make p is absolute

0 commit comments

Comments
 (0)