Browse Source

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: https://github.com/nodejs/node/pull/4959
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
v4.x
Rich Trott 9 years ago
committed by Myles Borins
parent
commit
1f8144200f
  1. 16
      lib/fs.js

16
lib/fs.js

@ -1367,18 +1367,14 @@ fs.unwatchFile = function(filename, listener) {
// Regexp that finds the next partion of a (partial) path // Regexp that finds the next partion of a (partial) path
// result is [base_with_slash, base], e.g. ['somedir/', 'somedir'] // result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
if (isWindows) { const nextPartRe = isWindows ?
var nextPartRe = /(.*?)(?:[\/\\]+|$)/g; /(.*?)(?:[\/\\]+|$)/g :
} else { /(.*?)(?:[\/]+|$)/g;
var nextPartRe = /(.*?)(?:[\/]+|$)/g;
}
// Regex to find the device root, including trailing slash. E.g. 'c:\\'. // Regex to find the device root, including trailing slash. E.g. 'c:\\'.
if (isWindows) { const splitRootRe = isWindows ?
var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/; /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/ :
} else { /^[\/]*/;
var splitRootRe = /^[\/]*/;
}
fs.realpathSync = function realpathSync(p, cache) { fs.realpathSync = function realpathSync(p, cache) {
// make p is absolute // make p is absolute

Loading…
Cancel
Save