feat: allow mkd command to create directories recursively (#294)
Co-authored-by: Bas Broerse <b.broerse@sector-orange.com>
This commit is contained in:
@@ -7,7 +7,7 @@ module.exports = {
|
||||
if (!this.fs) return this.reply(550, 'File system not instantiated');
|
||||
if (!this.fs.mkdir) return this.reply(402, 'Not supported by file system');
|
||||
|
||||
return Promise.try(() => this.fs.mkdir(command.arg))
|
||||
return Promise.try(() => this.fs.mkdir(command.arg, { recursive: true }))
|
||||
.then((dir) => {
|
||||
const path = dir ? `"${escapePath(dir)}"` : undefined;
|
||||
return this.reply(257, path);
|
||||
|
||||
@@ -119,7 +119,7 @@ class FileSystem {
|
||||
|
||||
mkdir(path) {
|
||||
const {fsPath} = this._resolvePath(path);
|
||||
return fsAsync.mkdir(fsPath)
|
||||
return fsAsync.mkdir(fsPath, { recursive: true })
|
||||
.then(() => fsPath);
|
||||
}
|
||||
|
||||
|
||||
@@ -338,6 +338,18 @@ describe('Integration', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('MKD témp multiple levels deep', (done) => {
|
||||
const path = `${clientDirectory}/${name}/témp/first/second`;
|
||||
if (fs.existsSync(path)) {
|
||||
fs.rmdirSync(path);
|
||||
}
|
||||
client.mkdir('témp/first/second', (err) => {
|
||||
expect(err).to.not.exist;
|
||||
expect(fs.existsSync(path)).to.equal(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('CWD témp', (done) => {
|
||||
client.cwd('témp', (err, data) => {
|
||||
expect(err).to.not.exist;
|
||||
|
||||
Reference in New Issue
Block a user