Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
27 lines
762 B
JavaScript
Executable file
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;
|