/usr/lib/nodejs/resolve-pkg/index.js is in node-resolve-pkg 0.2.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 | 'use strict';
var path = require('path');
var resolveFrom = require('resolve-from');
module.exports = function (moduleId, opts) {
opts = opts || {};
var parts = moduleId.replace(/\\/g, '/').split('/');
var packageName = '';
// handle scoped package name
if (parts.length > 0 && parts[0][0] === '@') {
packageName += parts.shift() + '/';
}
packageName += parts.shift();
var pkg = path.join(packageName, 'package.json');
var resolved = resolveFrom(opts.cwd || '.', pkg);
if (!resolved) {
return null;
}
return path.join(path.dirname(resolved), parts.join('/'));
};
|