Skip to content

Commit

Permalink
fix: create subdirectories when creating a new directory
Browse files Browse the repository at this point in the history
  • Loading branch information
rdeltour committed Oct 10, 2017
1 parent 3117085 commit ceed934
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/core/ace.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ module.exports = function ace(epubPath, options) {
if (typeof options.tmpdir === 'string') {
options.tmpdir = path.resolve(options.cwd, options.tmpdir);
if (!fs.existsSync(options.tmpdir)) {
fs.mkdirSync(options.tmpdir);
fs.ensureDirSync(options.tmpdir);
}
} else if (options.tmpdir === undefined) {
options.tmpdir = tmp.dirSync({ unsafeCleanup: true }).name;
}
if (typeof options.outdir === 'string') {
options.outdir = path.resolve(options.cwd, options.outdir);
if (!fs.existsSync(options.outdir)) {
fs.mkdirSync(options.outdir);
fs.ensureDirSync(options.outdir);
}
} else {
delete options.outdir;
Expand Down
2 changes: 1 addition & 1 deletion src/core/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const acePaths = envPaths('DAISY Ace', { suffix: null });
module.exports.initLogger = function initLogger(options = {}) {
// Check logging directoy exists
if (!fs.existsSync(acePaths.log)) {
fs.mkdirSync(acePaths.log);
fs.ensureDirSync(acePaths.log);
}

// OS-dependant path to log file
Expand Down
4 changes: 2 additions & 2 deletions src/report/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ module.exports = class Report {
if (this.json.data === null) return;
return fs.pathExists(outdir)
.then((exists) => {
if (!exists) fs.mkdirSync(outdir);
if (!exists) fs.ensureDirSync(outdir);
})
.then(() => {
if (this.json.data.images != null) {
Expand All @@ -108,7 +108,7 @@ module.exports = class Report {
winston.info("Saving JSON report");
return fs.pathExists(outdir)
.then((exists) => {
if (!exists) fs.mkdirSync(outdir);
if (!exists) fs.ensureDirSync(outdir);
})
.then(() => {
const aceReport = JSON.stringify(this.json, null, ' ');
Expand Down

0 comments on commit ceed934

Please sign in to comment.