From 5bd91acb86d64f03d16abdb186fe66ffa8a9f53a Mon Sep 17 00:00:00 2001 From: Merlin Beutlberger Date: Wed, 13 Mar 2019 10:30:31 +0100 Subject: [PATCH] [FEATURE] fsInterface: Add mkdir function When working with the UI5 adapters, it is not necessary to create directories. Therefore it's basically a noop --- lib/fsInterface.js | 12 ++++++++++-- test/lib/fsInterface.js | 10 ++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/fsInterface.js b/lib/fsInterface.js index 7df78413..adb0c0a6 100644 --- a/lib/fsInterface.js +++ b/lib/fsInterface.js @@ -1,10 +1,15 @@ /** - * Wraps readers to access them like a node fs-interface. + * Wraps readers to access them through a [Node.js fs]{@link https://nodejs.org/api/fs.html} styled interface. * * @public * @alias module:@ui5/fs.fsInterface * @param {module:@ui5/fs.AbstractReader} reader Resource Reader or Collection - * @returns {Object} Object with fs-style functions readFile, stat and readdir + * + * @returns {Object} Object with [Node.js fs]{@link https://nodejs.org/api/fs.html} styled functions + * [readFile]{@link https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback}, + * [stat]{@link https://nodejs.org/api/fs.html#fs_fs_stat_path_options_callback}, + * [readdir]{@link https://nodejs.org/api/fs.html#fs_fs_readdir_path_options_callback} and + * [mkdir]{@link https://nodejs.org/api/fs.html#fs_fs_mkdir_path_options_callback} */ module.exports = (reader) => { return { @@ -65,6 +70,9 @@ module.exports = (reader) => { }); callback(null, files); }).catch(callback); + }, + mkdir(path, callback) { + setTimeout(callback, 0); } }; }; diff --git a/test/lib/fsInterface.js b/test/lib/fsInterface.js index cbb90e43..1e35f356 100644 --- a/test/lib/fsInterface.js +++ b/test/lib/fsInterface.js @@ -100,3 +100,13 @@ test("fs: stat", (t) => { const stat = promisify(fs.stat); return assertStat(t, stat, path.join(__dirname, "..", "fixtures", "fsInterface"), "/foo.txt"); }); + +test("MemAdapter: mkdir", async (t) => { + const memAdapter = new MemAdapter({ + virBasePath: "/" + }); + const fs = fsInterface(memAdapter); + const mkdir = promisify(fs.mkdir); + + await t.notThrows(mkdir("pony"), "mkdir executes successfully"); +});