- Node >= 6.0.0
var mkfileSync = require('fs-force-mkfile-sync');
try {
let info = mkfileSync('./a/b/c/d', 'Hello, World!!');
console.log('Succeed');
} catch (error) {
console.log('Failed', info);
}
The code above would:
- First, do
force-mkdir
to create a directory'./a/b/c'
- Then, do
fs.writeFileSync
to create file'./a/b/c/d'
with content'Hello, World!!'