Skip to content

Commit 3d6c404

Browse files
TrottMyles Borins
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 de0e293 commit 3d6c404

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

lib/fs.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,18 +1367,14 @@ fs.unwatchFile = function(filename, listener) {
13671367

13681368
// Regexp that finds the next partion of a (partial) path
13691369
// result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
1370-
if (isWindows) {
1371-
var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
1372-
} else {
1373-
var nextPartRe = /(.*?)(?:[\/]+|$)/g;
1374-
}
1370+
const nextPartRe = isWindows ?
1371+
/(.*?)(?:[\/\\]+|$)/g :
1372+
/(.*?)(?:[\/]+|$)/g;
13751373

13761374
// Regex to find the device root, including trailing slash. E.g. 'c:\\'.
1377-
if (isWindows) {
1378-
var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
1379-
} else {
1380-
var splitRootRe = /^[\/]*/;
1381-
}
1375+
const splitRootRe = isWindows ?
1376+
/^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/ :
1377+
/^[\/]*/;
13821378

13831379
fs.realpathSync = function realpathSync(p, cache) {
13841380
// make p is absolute

0 commit comments

Comments
 (0)