@@ -4,6 +4,7 @@ const u = require('universalify').fromCallback
44const path = require ( 'path' )
55const fs = require ( 'graceful-fs' )
66const mkdir = require ( '../mkdirs' )
7+ const pathExists = require ( '../path-exists' ) . pathExists
78
89function createLink ( srcpath , dstpath , callback ) {
910 function makeLink ( srcpath , dstpath ) {
@@ -13,7 +14,8 @@ function createLink (srcpath, dstpath, callback) {
1314 } )
1415 }
1516
16- fs . exists ( dstpath , destinationExists => {
17+ pathExists ( dstpath , ( err , destinationExists ) => {
18+ if ( err ) return callback ( err )
1719 if ( destinationExists ) return callback ( null )
1820 fs . lstat ( srcpath , ( err , stat ) => {
1921 if ( err ) {
@@ -22,7 +24,8 @@ function createLink (srcpath, dstpath, callback) {
2224 }
2325
2426 const dir = path . dirname ( dstpath )
25- fs . exists ( dir , dirExists => {
27+ pathExists ( dir , ( err , dirExists ) => {
28+ if ( err ) return callback ( err )
2629 if ( dirExists ) return makeLink ( srcpath , dstpath )
2730 mkdir . mkdirs ( dir , err => {
2831 if ( err ) return callback ( err )
0 commit comments