fix: rename across directories working
This commit is contained in:
parent
5f872f0f24
commit
24697a3ed9
|
@ -2,6 +2,7 @@ node_modules
|
||||||
.env
|
.env
|
||||||
*~
|
*~
|
||||||
.vscode
|
.vscode
|
||||||
|
.idea
|
||||||
|
|
||||||
# Parcel build dirs
|
# Parcel build dirs
|
||||||
.cache
|
.cache
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -2326,7 +2326,7 @@ function rename(context, oldpath, newpath, callback) {
|
||||||
newpath = normalize(newpath);
|
newpath = normalize(newpath);
|
||||||
|
|
||||||
var oldParentPath = Path.dirname(oldpath);
|
var oldParentPath = Path.dirname(oldpath);
|
||||||
var newParentPath = Path.dirname(oldpath);
|
var newParentPath = Path.dirname(newpath);
|
||||||
var oldName = Path.basename(oldpath);
|
var oldName = Path.basename(oldpath);
|
||||||
var newName = Path.basename(newpath);
|
var newName = Path.basename(newpath);
|
||||||
var oldParentDirectory, oldParentData;
|
var oldParentDirectory, oldParentData;
|
||||||
|
|
|
@ -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) {
|
it('should rename an existing directory if the new path points to an existing directory', function(done) {
|
||||||
var fs = util.fs();
|
var fs = util.fs();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue