VulpesOS/gaia/tests/jsmarionette/runner/marionette-js-runner/lib/resolvemodule.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

27 lines
762 B
JavaScript
Executable file

'use strict';
var fsPath = require('path');
/**
* Resolves a path to a given module. This only works if the module exports a
* module from the root of its package (almost all modules ever).
*
* resolveModule('mocha', 'bin', '_mocha');
* // => /node_modules/(...)/mocha/bin/_mocha
*
* @private
* @param {String} module path.
* @param {...*} parts to extend path with.
* @return {String}
*/
function resolveModule(module, parts) {
var args = Array.prototype.slice.call(arguments);
parts = args.slice(1);
// resolve the module
var modulePath = fsPath.dirname(require.resolve(module));
// add given parts of the path to the module path.
return fsPath.join.apply(fsPath, [modulePath].concat(parts));
}
module.exports = resolveModule;