fix: rename across directories working

This commit is contained in:
Arun Bose 2021-10-16 18:06:13 +05:30 committed by David Humphrey
parent 5f872f0f24
commit 24697a3ed9
8 changed files with 29344 additions and 66 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@ node_modules
.env
*~
.vscode
.idea
# Parcel build dirs
.cache

10712
dist/filer.js vendored

File diff suppressed because it is too large Load Diff

2
dist/filer.js.map vendored

File diff suppressed because one or more lines are too long

182
dist/filer.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

18460
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2326,7 +2326,7 @@ function rename(context, oldpath, newpath, callback) {
newpath = normalize(newpath);
var oldParentPath = Path.dirname(oldpath);
var newParentPath = Path.dirname(oldpath);
var newParentPath = Path.dirname(newpath);
var oldName = Path.basename(oldpath);
var newName = Path.basename(newpath);
var oldParentDirectory, oldParentData;

View File

@ -108,6 +108,35 @@ describe('fs.rename', function() {
});
});
it('should rename an existing directory into another sub directory', () => {
var fsPromises = util.fs().promises;
return fsPromises.mkdir('/mydir')
.then(() => fsPromises.mkdir('/mydir/subdir'))
.then(() => fsPromises.mkdir('/anotherdir'))
.then(() => fsPromises.rename('/mydir', '/anotherdir/originaldir'))
.then(() => { fsPromises.stat('/mydir')
.catch((error) => {
expect(error).to.exist;
expect(error.code).to.equal('ENOENT');
});
})
.then(() => { fsPromises.stat('/anotherdir/mydir')
.catch((error) => {
expect(error).to.exist;
expect(error.code).to.equal('ENOENT');
});
})
.then(() => { fsPromises.stat('/anotherdir/originaldir/subdir')
.then(result => {
expect(result.nlinks).to.equal(1);
});
})
.catch((error) => {
if (error) throw error;
});
});
it('should rename an existing directory if the new path points to an existing directory', function(done) {
var fs = util.fs();