Skip to content

Commit

Permalink
lib/move: moving a file into an existing directory
Browse files Browse the repository at this point in the history
  • Loading branch information
kosmasgiannis committed Feb 3, 2015
1 parent 1eac26b commit 3ba42db
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/move.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@ function mv(source, dest, options, callback){
var clobber = options.clobber !== false
var limit = options.limit || 16

if (shouldMkdirp) {
mkdirs()
} else {
doRename()
}
fs.lstat(dest, function(err, statd) {

if ((statd) && (statd.isDirectory())) {
dest = path.join(dest, path.basename(source))
}

if (shouldMkdirp) {
mkdirs()
} else {
doRename()
}

})

function mkdirs() {
mkdirp(path.dirname(dest), function(err) {
Expand Down

0 comments on commit 3ba42db

Please sign in to comment.