@@ -1527,21 +1527,16 @@ fs.realpathSync = function realpathSync(p, options) {
1527
1527
// the partial path scanned in the previous round, with slash
1528
1528
var previous ;
1529
1529
1530
- start ( ) ;
1530
+ // Skip over roots
1531
+ var m = splitRootRe . exec ( p ) ;
1532
+ pos = m [ 0 ] . length ;
1533
+ current = m [ 0 ] ;
1534
+ base = m [ 0 ] ;
1531
1535
1532
- function start ( ) {
1533
- // Skip over roots
1534
- var m = splitRootRe . exec ( p ) ;
1535
- pos = m [ 0 ] . length ;
1536
- current = m [ 0 ] ;
1537
- base = m [ 0 ] ;
1538
- previous = '' ;
1539
-
1540
- // On windows, check that the root exists. On unix there is no need.
1541
- if ( isWindows && ! knownHard [ base ] ) {
1542
- fs . lstatSync ( base ) ;
1543
- knownHard [ base ] = true ;
1544
- }
1536
+ // On windows, check that the root exists. On unix there is no need.
1537
+ if ( isWindows && ! knownHard [ base ] ) {
1538
+ fs . lstatSync ( base ) ;
1539
+ knownHard [ base ] = true ;
1545
1540
}
1546
1541
1547
1542
// walk down the path, swapping out linked pathparts for their real
@@ -1595,7 +1590,18 @@ fs.realpathSync = function realpathSync(p, options) {
1595
1590
1596
1591
// resolve the link, then start over
1597
1592
p = pathModule . resolve ( resolvedLink , p . slice ( pos ) ) ;
1598
- start ( ) ;
1593
+
1594
+ // Skip over roots
1595
+ m = splitRootRe . exec ( p ) ;
1596
+ pos = m [ 0 ] . length ;
1597
+ current = m [ 0 ] ;
1598
+ base = m [ 0 ] ;
1599
+
1600
+ // On windows, check that the root exists. On unix there is no need.
1601
+ if ( isWindows && ! knownHard [ base ] ) {
1602
+ fs . lstatSync ( base ) ;
1603
+ knownHard [ base ] = true ;
1604
+ }
1599
1605
}
1600
1606
1601
1607
if ( cache ) cache . set ( original , p ) ;
@@ -1626,26 +1632,21 @@ fs.realpath = function realpath(p, options, callback) {
1626
1632
// the partial path scanned in the previous round, with slash
1627
1633
var previous ;
1628
1634
1629
- start ( ) ;
1630
-
1631
- function start ( ) {
1632
- // Skip over roots
1633
- var m = splitRootRe . exec ( p ) ;
1634
- pos = m [ 0 ] . length ;
1635
- current = m [ 0 ] ;
1636
- base = m [ 0 ] ;
1637
- previous = '' ;
1635
+ var m = splitRootRe . exec ( p ) ;
1636
+ pos = m [ 0 ] . length ;
1637
+ current = m [ 0 ] ;
1638
+ base = m [ 0 ] ;
1639
+ previous = '' ;
1638
1640
1639
- // On windows, check that the root exists. On unix there is no need.
1640
- if ( isWindows && ! knownHard [ base ] ) {
1641
- fs . lstat ( base , function ( err ) {
1642
- if ( err ) return callback ( err ) ;
1643
- knownHard [ base ] = true ;
1644
- LOOP ( ) ;
1645
- } ) ;
1646
- } else {
1647
- process . nextTick ( LOOP ) ;
1648
- }
1641
+ // On windows, check that the root exists. On unix there is no need.
1642
+ if ( isWindows && ! knownHard [ base ] ) {
1643
+ fs . lstat ( base , function ( err ) {
1644
+ if ( err ) return callback ( err ) ;
1645
+ knownHard [ base ] = true ;
1646
+ LOOP ( ) ;
1647
+ } ) ;
1648
+ } else {
1649
+ process . nextTick ( LOOP ) ;
1649
1650
}
1650
1651
1651
1652
// walk down the path, swapping out linked pathparts for their real
@@ -1711,7 +1712,22 @@ fs.realpath = function realpath(p, options, callback) {
1711
1712
function gotResolvedLink ( resolvedLink ) {
1712
1713
// resolve the link, then start over
1713
1714
p = pathModule . resolve ( resolvedLink , p . slice ( pos ) ) ;
1714
- start ( ) ;
1715
+ var m = splitRootRe . exec ( p ) ;
1716
+ pos = m [ 0 ] . length ;
1717
+ current = m [ 0 ] ;
1718
+ base = m [ 0 ] ;
1719
+ previous = '' ;
1720
+
1721
+ // On windows, check that the root exists. On unix there is no need.
1722
+ if ( isWindows && ! knownHard [ base ] ) {
1723
+ fs . lstat ( base , function ( err ) {
1724
+ if ( err ) return callback ( err ) ;
1725
+ knownHard [ base ] = true ;
1726
+ LOOP ( ) ;
1727
+ } ) ;
1728
+ } else {
1729
+ process . nextTick ( LOOP ) ;
1730
+ }
1715
1731
}
1716
1732
} ;
1717
1733
0 commit comments