feat: allow mkd command to create directories recursively (#294)

Co-authored-by: Bas Broerse <b.broerse@sector-orange.com>
This commit is contained in:
Bas Broerse
2022-04-14 22:43:33 +02:00
committed by GitHub
parent 4eb17015f1
commit 32a0750e2c
3 changed files with 14 additions and 2 deletions

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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;