Skip to content

Commit

Permalink
Ensure creation of parent directory on touchFileSync method
Browse files Browse the repository at this point in the history
  • Loading branch information
klaudiosinani committed Dec 15, 2018
1 parent 71c1221 commit 61d1a13
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/util.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
const {join} = require('path');
const {dirname, join} = require('path');
const fs = require('fs');
const decodeUri = require('decode-uri-component');
const url = require('./url');
Expand Down Expand Up @@ -45,8 +45,13 @@ class Util {
}

touchFileSync(x) {
const dir = dirname(x);

if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}

return fs.closeSync(fs.openSync(x, 'a'));
}
}

module.exports = new Util();

0 comments on commit 61d1a13

Please sign in to comment.