emmaramirez.me
Version:
emma's personal website
21 lines (16 loc) • 452 B
text/typescript
const fs = require('fs');
const ensureExists = (path: string, mask?: any, cb?: any) => {
if (typeof mask === 'function') {
cb = mask;
mask = 0o777;
}
fs.mkdir(path, mask, (err: any) => {
if (err) {
if (err.code === 'EEXIST') cb(null);
else cb(err);
} else {
cb(null);
}
});
};
module.exports = ensureExists;