Add options argument for Zotero.File.createDirectoryIfMissingAsync()

To allow passing 'from' argument through to OS.File.makeDir()
This commit is contained in:
Dan Stillman 2021-01-20 06:36:57 -05:00
parent 2a203afb20
commit 8c464a7a8b
2 changed files with 15 additions and 5 deletions

View file

@ -1010,14 +1010,17 @@ Zotero.File = new function(){
}
this.createDirectoryIfMissingAsync = async function (path) {
this.createDirectoryIfMissingAsync = async function (path, options = {}) {
try {
await OS.File.makeDir(
path,
{
ignoreExisting: false,
unixMode: 0o755
}
Object.assign(
{
ignoreExisting: false,
unixMode: 0o755
},
options
)
)
}
catch (e) {

View file

@ -293,6 +293,13 @@ describe("Zotero.File", function () {
assert.ok(e);
assert.match(e.message, /^Broken symlink/);
});
it("should handle 'from' in options", async function () {
var tmpPath = await getTempDirectory();
var path = OS.Path.join(tmpPath, 'a', 'b');
await Zotero.File.createDirectoryIfMissingAsync(path, { from: tmpPath });
assert.isTrue(await OS.File.exists(path));
});
});
describe("#zipDirectory()", function () {