Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 3x 3x 3x 3x 650x 650x 650x 650x 941x 650x 650x 632x 632x 632x | 'use strict';
let fs;
try {
fs = require('fs/promises');
} catch(error) {
fs = require('fs').promises;
}
const path = require('path');
module.exports = async function(sources) {
let {0: [file]} = sources;
let dir = path.dirname(file);
await safeMkdir(dir);
/*
first: path to output file
second: contents
*/
return Promise.all(
sources.map(args => fs.writeFile(...args))
);
};
async function safeMkdir(dir) {
try {
await fs.stat(dir);
} catch (error) {
Eif (error.code === 'ENOENT') {
try {
await fs.mkdir(dir);
} catch ({}) {
// suppressed?
}
}
}
}
|