fs-extra
Advanced tools
Comparing version 0.23.0 to 0.23.1
@@ -0,1 +1,6 @@ | ||
0.23.1 / 2015-08-07 | ||
------------------- | ||
- Better handling of errors for `move()` when moving across devices. https://github.com/jprichardson/node-fs-extra/pull/170 | ||
- `ensureSymlink()` and `ensureLink()` should not throw errors if link exists. https://github.com/jprichardson/node-fs-extra/pull/169 | ||
0.23.0 / 2015-08-06 | ||
@@ -2,0 +7,0 @@ ------------------- |
@@ -13,14 +13,16 @@ var path = require('path') | ||
fs.lstat(srcpath, function (err, stat) { | ||
if (err) { | ||
err.message = err.message.replace('lstat', 'ensureLink') | ||
return callback(err) | ||
} | ||
var dir = path.dirname(dstpath) | ||
fs.exists(dir, function (dirExists) { | ||
if (dirExists) return makeLink(srcpath, dstpath) | ||
mkdir.mkdirs(dir, function (err) { | ||
if (err) return callback(err) | ||
makeLink(srcpath, dstpath) | ||
fs.exists(dstpath, function (destinationExists) { | ||
if (destinationExists) return callback(null) | ||
fs.lstat(srcpath, function (err, stat) { | ||
if (err) { | ||
err.message = err.message.replace('lstat', 'ensureLink') | ||
return callback(err) | ||
} | ||
var dir = path.dirname(dstpath) | ||
fs.exists(dir, function (dirExists) { | ||
if (dirExists) return makeLink(srcpath, dstpath) | ||
mkdir.mkdirs(dir, function (err) { | ||
if (err) return callback(err) | ||
makeLink(srcpath, dstpath) | ||
}) | ||
}) | ||
@@ -33,2 +35,5 @@ }) | ||
var destinationExists = fs.existsSync(dstpath) | ||
if (destinationExists) return undefined | ||
try { | ||
@@ -45,2 +50,3 @@ fs.lstatSync(srcpath) | ||
mkdir.mkdirsSync(dir) | ||
return fs.linkSync(srcpath, dstpath) | ||
@@ -47,0 +53,0 @@ } |
@@ -18,13 +18,17 @@ var path = require('path') | ||
type = (typeof type === 'function') ? false : type | ||
symlinkPaths(srcpath, dstpath, function (err, relative) { | ||
if (err) return callback(err) | ||
srcpath = relative.toDst | ||
symlinkType(relative.toCwd, type, function (err, type) { | ||
fs.exists(dstpath, function (destinationExists) { | ||
if (destinationExists) return callback(null) | ||
symlinkPaths(srcpath, dstpath, function (err, relative) { | ||
if (err) return callback(err) | ||
var dir = path.dirname(dstpath) | ||
fs.exists(dir, function (dirExists) { | ||
if (dirExists) return fs.symlink(srcpath, dstpath, type, callback) | ||
mkdirs(dir, function (err) { | ||
if (err) return callback(err) | ||
fs.symlink(srcpath, dstpath, type, callback) | ||
srcpath = relative.toDst | ||
symlinkType(relative.toCwd, type, function (err, type) { | ||
if (err) return callback(err) | ||
var dir = path.dirname(dstpath) | ||
fs.exists(dir, function (dirExists) { | ||
if (dirExists) return fs.symlink(srcpath, dstpath, type, callback) | ||
mkdirs(dir, function (err) { | ||
if (err) return callback(err) | ||
fs.symlink(srcpath, dstpath, type, callback) | ||
}) | ||
}) | ||
@@ -39,2 +43,6 @@ }) | ||
type = (typeof type === 'function') ? false : type | ||
var destinationExists = fs.existsSync(dstpath) | ||
if (destinationExists) return undefined | ||
var relative = symlinkPathsSync(srcpath, dstpath) | ||
@@ -41,0 +49,0 @@ srcpath = relative.toDst |
@@ -64,3 +64,3 @@ // most of this code was written by Andrew Kelley | ||
if (err.code !== 'EXDEV') return callback(err) | ||
moveFileAcrossDevice(source, dest, clobber, limit, callback) | ||
moveAcrossDevice(source, dest, clobber, limit, callback) | ||
}) | ||
@@ -70,10 +70,6 @@ } else { | ||
if (err) { | ||
if (err.code === 'EXDEV') { | ||
moveFileAcrossDevice(source, dest, clobber, limit, callback) | ||
if (err.code === 'EXDEV' || err.code === 'EISDIR' || err.code === 'EPERM') { | ||
moveAcrossDevice(source, dest, clobber, limit, callback) | ||
return | ||
} | ||
if (err.code === 'EISDIR' || err.code === 'EPERM') { | ||
moveDirAcrossDevice(source, dest, clobber, limit, callback) | ||
return | ||
} | ||
callback(err) | ||
@@ -88,2 +84,17 @@ return | ||
function moveAcrossDevice (source, dest, clobber, limit, callback) { | ||
fs.stat(source, function (err, stat) { | ||
if (err) { | ||
callback(err) | ||
return | ||
} | ||
if (stat.isDirectory()) { | ||
moveDirAcrossDevice(source, dest, clobber, limit, callback) | ||
} else { | ||
moveFileAcrossDevice(source, dest, clobber, limit, callback) | ||
} | ||
}) | ||
} | ||
function moveFileAcrossDevice (source, dest, clobber, limit, callback) { | ||
@@ -90,0 +101,0 @@ var outFlags = clobber ? 'w' : 'wx' |
{ | ||
"name": "fs-extra", | ||
"version": "0.23.0", | ||
"version": "0.23.1", | ||
"description": "fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as mkdir -p, cp -r, and rm -rf.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/jprichardson/node-fs-extra", |
61573
1158