Is this the right way to create a directory if it doesn\'t exist. It should have full permission for the script and readable by others.
var dir = __dirname +
Using async / await:
const mkdirP = async (directory) => { try { return await fs.mkdirAsync(directory); } catch (error) { if (error.code != 'EEXIST') { throw e; } } };
You will need to promisify fs:
fs
import nodeFs from 'fs'; import bluebird from 'bluebird'; const fs = bluebird.promisifyAll(nodeFs);