/usr/lib/nodejs/write-file-promise/index.js is in node-write-file-promise 1.0.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | var path = require('path');
var fs = require('fs');
function mkdirp (filePath) {
var dir = path.dirname(filePath);
try {
fs.readdirSync(dir);
} catch (err) {
mkdirp(dir);
fs.mkdirSync(dir);
}
}
module.exports = function (file, data, options) {
return new Promise(function (resolve, reject) {
mkdirp(file);
fs.writeFile(file, data, options, function (err) {
if (err) {
reject(err);
} else {
resolve();
}
});
});
}
|