docs(changelog test): i test how to automate ChangeLog
This commit is contained in:
44
node_modules/find-node-modules/README.md
generated
vendored
Normal file
44
node_modules/find-node-modules/README.md
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
# find-node-modules
|
||||
|
||||
This is a little node module to find the path of every parent node_modules
|
||||
directory. It's useful for things like Sass, where you can't specify the exact
|
||||
path to individual modules (in which case [findup-sync] would be sufficient),
|
||||
and you can't just give an array of parent node_modules which might exist,
|
||||
because it will error if they don't.
|
||||
|
||||
In most cases you're trying to find node_modules directories, findup-sync
|
||||
should be sufficient. This library is specifically for if you want an array
|
||||
containing all the parent node_modules paths. If you loop through the output
|
||||
of this library, you should be using findup-sync instead.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save find-node-modules
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var findNodeModules = require('find-node-modules');
|
||||
|
||||
findNodeModules();
|
||||
//=> ['node_modules', '../../node_modules']
|
||||
|
||||
findNodeModules({ cwd: './someDir' });
|
||||
//=> ['../node_modules', '../../../node_modules']
|
||||
|
||||
findNodeModules('./someDir');
|
||||
//=> ['../node_modules', '../../../node_modules']
|
||||
|
||||
findNodeModules({ cwd: './someDir', relative: false });
|
||||
//=> ['/path/to/something/node_modules', '/path/node_modules']
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
This is released under the MIT license.
|
||||
|
||||
|
||||
|
||||
[findup-sync]: https://www.npmjs.com/package/findup-sync
|
62
node_modules/find-node-modules/index.js
generated
vendored
Normal file
62
node_modules/find-node-modules/index.js
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
var findup = require('findup-sync');
|
||||
var merge = require('merge');
|
||||
|
||||
/**
|
||||
* Finds all parents node_modules directories and returns them in an array.
|
||||
*
|
||||
* @param {object} options An object containing objects. Read the readme or
|
||||
* the source code.
|
||||
*/
|
||||
module.exports = function findNodeModules(options) {
|
||||
if (typeof options === 'string') {
|
||||
options = {
|
||||
cwd: options
|
||||
};
|
||||
}
|
||||
|
||||
options = merge({
|
||||
cwd: process.cwd(), // The directory to start the search from
|
||||
searchFor: 'node_modules', // I see no reason to change this
|
||||
relative: true // If false, returns absolute paths
|
||||
}, options);
|
||||
|
||||
var modulesArray = [];
|
||||
var searchDir = options.cwd;
|
||||
var modulesDir;
|
||||
var duplicateFound = false;
|
||||
|
||||
do {
|
||||
modulesDir = findup(options.searchFor, { cwd: searchDir });
|
||||
|
||||
if (modulesDir !== null) {
|
||||
var foundModulesDir = formatPath(modulesDir, options);
|
||||
duplicateFound = (modulesArray.indexOf(foundModulesDir) > -1);
|
||||
if (!duplicateFound) {
|
||||
modulesArray.push(foundModulesDir);
|
||||
searchDir = path.join(modulesDir, '../../');
|
||||
}
|
||||
}
|
||||
} while (modulesDir && !duplicateFound);
|
||||
|
||||
return modulesArray;
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal function to return either a relative or an absolute path depending
|
||||
* on an option. Basically not very useful, could be inline.
|
||||
*
|
||||
* @param {string} modulesDir The absolute path
|
||||
* @param {object} options Options object containing relative boolean and cwd
|
||||
* @returns {string} Either an absolute path or a relative path
|
||||
* @private
|
||||
*/
|
||||
function formatPath(modulesDir, options) {
|
||||
if (options.relative) {
|
||||
return path.relative(options.cwd, modulesDir);
|
||||
} else {
|
||||
return modulesDir;
|
||||
}
|
||||
}
|
27
node_modules/find-node-modules/package.json
generated
vendored
Normal file
27
node_modules/find-node-modules/package.json
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "find-node-modules",
|
||||
"version": "2.1.3",
|
||||
"description": "Return an array of all parent node_modules directories",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "node ./test | faucet"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/callumacrae/find-node-modules"
|
||||
},
|
||||
"author": "Callum Macrae <callum@macr.ae>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/callumacrae/find-node-modules/issues"
|
||||
},
|
||||
"homepage": "https://github.com/callumacrae/find-node-modules",
|
||||
"dependencies": {
|
||||
"findup-sync": "^4.0.0",
|
||||
"merge": "^2.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"faucet": "0.0.1",
|
||||
"tape": "4.6.0"
|
||||
}
|
||||
}
|
33
node_modules/find-node-modules/test.js
generated
vendored
Normal file
33
node_modules/find-node-modules/test.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
var test = require('tape');
|
||||
var findNodeModules = require('./');
|
||||
|
||||
test('find-node-modules', function (t) {
|
||||
t.plan(5);
|
||||
|
||||
t.deepEquals(findNodeModules(), ['node_modules']);
|
||||
|
||||
t.deepEquals(findNodeModules('test/b/c/d'), [
|
||||
'node_modules', '../node_modules', '../../../node_modules', '../../../../node_modules'
|
||||
]);
|
||||
|
||||
t.deepEquals(findNodeModules('test/b/c/d/e/f'), [
|
||||
'node_modules', '../../node_modules', '../../../node_modules',
|
||||
'../../../../../node_modules', '../../../../../../node_modules'
|
||||
]);
|
||||
|
||||
t.deepEquals(findNodeModules({ cwd: 'test/b/c/d' }), [
|
||||
'node_modules', '../node_modules', '../../../node_modules', '../../../../node_modules'
|
||||
]);
|
||||
|
||||
var cwd = process.cwd();
|
||||
|
||||
t.deepEquals(findNodeModules({ cwd: 'test/b/c/d', relative: false }), [
|
||||
path.join(cwd, 'test/b/c/d/node_modules'),
|
||||
path.join(cwd, 'test/b/c/node_modules'),
|
||||
path.join(cwd, 'test/node_modules'),
|
||||
path.join(cwd, 'node_modules')
|
||||
]);
|
||||
});
|
0
node_modules/find-node-modules/test/b/c/d/e/f/node_modules/blank
generated
vendored
Normal file
0
node_modules/find-node-modules/test/b/c/d/e/f/node_modules/blank
generated
vendored
Normal file
0
node_modules/find-node-modules/test/b/c/d/node_modules/blank
generated
vendored
Normal file
0
node_modules/find-node-modules/test/b/c/d/node_modules/blank
generated
vendored
Normal file
0
node_modules/find-node-modules/test/b/c/node_modules/blank
generated
vendored
Normal file
0
node_modules/find-node-modules/test/b/c/node_modules/blank
generated
vendored
Normal file
0
node_modules/find-node-modules/test/node_modules/blank
generated
vendored
Normal file
0
node_modules/find-node-modules/test/node_modules/blank
generated
vendored
Normal file
Reference in New Issue
Block a user