Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!Buffer.isBuffer(content)) {
// TODO need remove in next major release
if (Array.isArray(content)) {
content = content.join('\n');
}
content = Buffer.from(content, 'utf8');
}
mkdirp.sync(path.dirname(targetPath));
try {
fs.writeFileSync(targetPath, content, 'utf-8');
log.debug(
colors.cyan(
`Asset written to disk: ${path.relative(
process.cwd(),
targetPath
)}`
)
);
} catch (e) {
log.error(`Unable to write asset to disk:\n${e}`);
}
}
}
});
}
return fs.writeFile(targetPath, content, (writeFileError) => {
if (writeFileError) {
return callback(writeFileError);
}
log.debug(
colors.cyan(
`Asset written to disk: ${path.relative(
process.cwd(),
targetPath
)}`
)
);
return callback();
});
});