/usr/lib/nodejs/require-relative/index.js is in node-require-relative 0.8.7-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 | /*
relative require
*/'use strict';
var path = require('path');
var Module = require('module');
var modules = {};
var getModule = function(dir) {
var rootPath = dir ? path.resolve(dir) : process.cwd();
var rootName = path.join(rootPath, '@root');
var root = modules[rootName];
if (!root) {
root = new Module(rootName);
root.filename = rootName;
root.paths = Module._nodeModulePaths(rootPath);
modules[rootName] = root;
}
return root;
};
var requireRelative = function(requested, relativeTo) {
var root = getModule(relativeTo);
return root.require(requested);
};
requireRelative.resolve = function(requested, relativeTo) {
var root = getModule(relativeTo);
return Module._resolveFilename(requested, root);
};
module.exports = requireRelative;
|