Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function writeFile(file, content) {
try {
mkdirp.sync(path.dirname(file));
fs.writeFileSync(file, content);
return file;
} catch (e) {
return null;
}
}
function writeFiles(files) {
var written = 0;
for (var key in files) {
if (_.isObject(files[key])) {
if (files[key].constructor === File) {
mkdirp.sync(path.dirname(files[key].path));
fs.writeFileSync(files[key].path, files[key].contents);
++written;
} else {
written += writeFiles(files[key]);
}
}
}
return written;
}