Add options
argument for Zotero.File.createDirectoryIfMissingAsync()
To allow passing 'from' argument through to OS.File.makeDir()
This commit is contained in:
parent
2a203afb20
commit
8c464a7a8b
2 changed files with 15 additions and 5 deletions
|
@ -1010,14 +1010,17 @@ Zotero.File = new function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
this.createDirectoryIfMissingAsync = async function (path) {
|
this.createDirectoryIfMissingAsync = async function (path, options = {}) {
|
||||||
try {
|
try {
|
||||||
await OS.File.makeDir(
|
await OS.File.makeDir(
|
||||||
path,
|
path,
|
||||||
{
|
Object.assign(
|
||||||
ignoreExisting: false,
|
{
|
||||||
unixMode: 0o755
|
ignoreExisting: false,
|
||||||
}
|
unixMode: 0o755
|
||||||
|
},
|
||||||
|
options
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
|
|
@ -293,6 +293,13 @@ describe("Zotero.File", function () {
|
||||||
assert.ok(e);
|
assert.ok(e);
|
||||||
assert.match(e.message, /^Broken symlink/);
|
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 () {
|
describe("#zipDirectory()", function () {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue