OpenAsar/polyfills/mkdirp.js

21 lines
465 B
JavaScript
Raw Normal View History

// Minimal wrapper mimicking mkdirp package
const fs = require('fs');
const async = (path, callback) => { // async
log('Mkdirp', 'Async:', path);
2021-12-11 08:23:29 +00:00
fs.mkdir(path, { recursive: true }, () => { // Ignore errors (already exists)
callback();
2021-12-11 08:23:29 +00:00
});
};
const sync = (path) => { // sync
log('Mkdirp', 'Sync:', path);
try {
fs.mkdirSync(path, { recursive: true });
} catch (e) { } // Already exists, ignore
};
2022-01-14 13:54:18 +00:00
async.sync = sync;
module.exports = async;