/usr/lib/nodejs/roadrunner/index.js is in node-roadrunner 1.1.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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | "use strict";
var Module = require("module");
var fs = require("fs");
var FILENAME = ".roadrunner.json";
var data = {};
var wrap = function (fn) {
return function (filename) {
filename = filename || FILENAME;
return fn(filename);
};
};
var init = function () {
Module._pathCache = exports.get("path");
Module._realpathCache = exports.get("realpath");
};
exports.save = wrap(function (filename) {
exports.set("realpath", Module._realpathCache);
exports.set("path", Module._pathCache);
fs.writeFileSync(filename, JSON.stringify(data, null, " "));
});
exports.load = wrap(function (filename) {
if (!fs.existsSync(filename)) return;
try {
data = JSON.parse(fs.readFileSync(filename));
} catch (err) {
return;
}
init();
});
exports.setup = wrap(function (filename) {
var save = exports.save.bind(null, filename);
process.on("exit", save);
process.on("SIGINT", function sigint() {
process.removeListener("SIGINT", sigint);
save();
process.kill(process.pid, "SIGINT");
});
});
exports.reset = wrap(function (filename) {
if (fs.existsSync(filename)) fs.unlinkSync(filename);
data = {};
init();
});
exports.get = function (key) {
return data[key] = data[key] || {};
};
exports.set = function (key, val) {
return data[key] = val;
};
|