pax_global_header00006660000000000000000000000064131456674060014526gustar00rootroot0000000000000052 comment=5d2e1bc61127ec6d0c95019a234daca40d2cb830 js-matchdep-2.0.0/000077500000000000000000000000001314566740600137245ustar00rootroot00000000000000js-matchdep-2.0.0/.gitignore000066400000000000000000000000171314566740600157120ustar00rootroot00000000000000/node_modules/ js-matchdep-2.0.0/.jshintrc000066400000000000000000000003451314566740600155530ustar00rootroot00000000000000{ "loopfunc": true, "curly": true, "eqeqeq": true, "immed": true, "latedef": true, "newcap": true, "noarg": true, "sub": true, "undef": true, "unused": true, "boss": true, "eqnull": true, "node": true } js-matchdep-2.0.0/.npmignore000066400000000000000000000000211314566740600157140ustar00rootroot00000000000000test Gruntfile.jsjs-matchdep-2.0.0/.travis.yml000066400000000000000000000002021314566740600160270ustar00rootroot00000000000000sudo: false language: node_js node_js: - "0.10" - "0.12" - "4" - "6" - "8" before_install: - npm install -g grunt-cli js-matchdep-2.0.0/Gruntfile.js000066400000000000000000000007561314566740600162310ustar00rootroot00000000000000'use strict'; module.exports = function(grunt) { // Project configuration. grunt.initConfig({ jshint: { options: { jshintrc: '.jshintrc' }, all: ['Gruntfile.js', 'lib/**/*.js', 'test/**/*.js'] }, nodeunit: { files: ['test/**/*_test.js'], } }); // Load plugins. grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-nodeunit'); // Default task. grunt.registerTask('default', ['jshint', 'nodeunit']); }; js-matchdep-2.0.0/LICENSE-MIT000066400000000000000000000020401314566740600153540ustar00rootroot00000000000000Copyright (c) 2013 Tyler Kellen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. js-matchdep-2.0.0/README.md000066400000000000000000000035751314566740600152150ustar00rootroot00000000000000# matchdep [![Build Status](https://secure.travis-ci.org/tkellen/js-matchdep.svg?branch=master)](http://travis-ci.org/tkellen/js-matchdep) > Use [micromatch] to filter npm module dependencies by name. [![NPM](https://nodei.co/npm/matchdep.png)](https://nodei.co/npm/matchdep/) ## Examples ```js var matchdep = require('matchdep'); // Filter dependencies (by autoloading nearest package.json) matchdep.filter('mini*'); // Filter devDependencies (with config string indicating file to be required) matchdep.filterDev('grunt-contrib-*', './package.json'); // Filter peerDependencies (with config string indicating file to be required) matchdep.filterPeer('foo-{bar,baz}', './some-other.json'); // Filter all dependencies (with explicit config provided) matchdep.filterAll('*', require('./yet-another.json')); // Filter all dependencies, exclude grunt (multiple matching patterns) matchdep.filterAll(['*','!grunt']); ``` ## Usage ```js filter(pattern, config) filterDev(pattern, config) filterPeer(pattern, config) filterAll(pattern, config) ``` ### pattern Type: `String|Array` Default: 'none' A [micromatch] compatible match pattern to filter dependencies. ### config Type: `String` or `Object` Default: Path to nearest package.json. If config is a string, matchdep will attempt to require it. If it is an object, it will be used directly. ## Release History * 2017-08-18 - v2.0.0 - Upgrade major versions of dependencies, Upgrade devDeps * 2016-02-09 - v1.0.1 - switch to [micromatch], remove [globule] * 2015-09-27 - v1.0.0 - throw when no package.json found, update dependencies, remove node 0.8 support * 2013-10-09 - v0.3.0 - support multiple pattern matches using [globule] * 2013-10-08 - v0.2.0 - refactor and support filtering peerDependencies * 2012-11-27 - v0.1.0 - initial release [globule]: https://github.com/cowboy/node-globule [micromatch]: https://github.com/jonschlinkert/micromatch js-matchdep-2.0.0/lib/000077500000000000000000000000001314566740600144725ustar00rootroot00000000000000js-matchdep-2.0.0/lib/matchdep.js000066400000000000000000000044751314566740600166270ustar00rootroot00000000000000/* * matchdep * https://github.com/tkellen/node-matchdep * * Copyright (c) 2012 Tyler Kellen * Licensed under the MIT license. */ 'use strict'; var micromatch = require('micromatch'); var findup = require('findup-sync'); var resolve = require('resolve').sync; var stackTrace = require('stack-trace'); var path = require('path'); // export object var matchdep = module.exports = {}; // Ensure configuration has the correct properties. function loadConfig(config, props) { // The calling module's path. Unfortunately, because modules are cached, // module.parent is the FIRST calling module parent, not necessarily the // current one. var callerPath = path.dirname(stackTrace.get(loadConfig)[1].getFileName()); // If no config defined, resolve to nearest package.json to the calling lib. If not found, throw an error. if (config == null) { config = findup('package.json', {cwd: callerPath}); if (config == null) { throw new Error('No package.json found.'); } } // If filename was specified with no path parts, make the path absolute so // that resolve doesn't look in node_module directories for it. else if (typeof config === 'string' && !/[\\\/]/.test(config)) { config = path.join(callerPath, config); } // If package is a string, try to require it. if (typeof config === 'string') { config = require(resolve(config, {basedir: callerPath})); } // If config is not an object yet, something is amiss. if (typeof config !== 'object') { throw new Error('Invalid configuration specified.'); } // For all specified props, populate result object. var result = {}; props.forEach(function(prop) { result[prop] = config[prop] ? Object.keys(config[prop]) : []; }); return result; } // What config properties should each method search? var methods = { filter: ['dependencies'], filterDev: ['devDependencies'], filterPeer: ['peerDependencies'], filterAll: ['dependencies', 'devDependencies', 'peerDependencies'], }; // Dynamically generate methods. Object.keys(methods).forEach(function(method) { var props = methods[method]; matchdep[method] = function(pattern, config) { config = loadConfig(config, props); var search = props.reduce(function(result, prop) { return result.concat(config[prop]); }, []); return micromatch(search, pattern); }; }); js-matchdep-2.0.0/package.json000066400000000000000000000016511314566740600162150ustar00rootroot00000000000000{ "name": "matchdep", "description": "Use micromatch to filter npm module dependencies by name.", "version": "2.0.0", "homepage": "https://github.com/tkellen/js-matchdep", "author": { "name": "Tyler Kellen", "url": "http://goingslowly.com/" }, "repository": { "type": "git", "url": "git://github.com/tkellen/js-matchdep.git" }, "bugs": { "url": "https://github.com/tkellen/js-matchdep/issues" }, "license": "MIT", "main": "lib/matchdep", "engines": { "node": ">= 0.10.0" }, "scripts": { "test": "grunt" }, "dependencies": { "findup-sync": "^2.0.0", "micromatch": "^3.0.4", "resolve": "^1.4.0", "stack-trace": "0.0.10" }, "devDependencies": { "grunt": "^1.0.1", "grunt-contrib-jshint": "^1.1.0", "grunt-contrib-nodeunit": "^1.0.0" }, "keywords": [ "package.json", "dependencies", "devDependencies", "peerDependencies" ] } js-matchdep-2.0.0/test/000077500000000000000000000000001314566740600147035ustar00rootroot00000000000000js-matchdep-2.0.0/test/fixtures/000077500000000000000000000000001314566740600165545ustar00rootroot00000000000000js-matchdep-2.0.0/test/fixtures/package.json000066400000000000000000000001401314566740600210350ustar00rootroot00000000000000{ "dependencies": { "pkg-1": "~1.2.3", "pkg-2": "~1.2.3", "pkg-3": "~1.2.3" } } js-matchdep-2.0.0/test/fixtures/sample.json000066400000000000000000000004441314566740600207320ustar00rootroot00000000000000{ "dependencies": { "dep-1": "~1.2.3", "dep-2": "~1.2.3", "dep-3": "~1.2.3" }, "devDependencies": { "dev-1": "~1.2.3", "dev-2": "~1.2.3", "dev-3": "~1.2.3" }, "peerDependencies": { "peer-1": "~1.2.3", "peer-2": "~1.2.3", "peer-3": "~1.2.3" } } js-matchdep-2.0.0/test/fixtures/submodule.js000066400000000000000000000007541314566740600211170ustar00rootroot00000000000000var matchdep = require('../../lib/matchdep'); exports.defaultConfig = function() { return matchdep.filter('*'); }; exports.fileConfig = function() { return matchdep.filter('*', 'package.json'); }; exports.relativeConfig = function() { return matchdep.filter('*', './package.json'); }; exports.relativeConfig2 = function() { return matchdep.filter('*', '../../package.json'); }; exports.absoluteConfig = function() { return matchdep.filter('*', __dirname + '/package.json'); }; js-matchdep-2.0.0/test/matchdep_test.js000066400000000000000000000055171314566740600200750ustar00rootroot00000000000000'use strict'; var matchdep = require('../lib/matchdep'); exports['matchdep'] = { setUp: function(done) { this.fixture = __dirname + '/fixtures/sample.json'; done(); }, filter: function(test) { test.expect(1); test.equal(matchdep.filter('*', this.fixture).join(), 'dep-1,dep-2,dep-3', 'should find all dependencies matching "*"'); test.done(); }, filterDev: function(test) { test.expect(1); test.equal(matchdep.filterDev('*', this.fixture).join(), 'dev-1,dev-2,dev-3', 'should find all devDependencies matching "*"'); test.done(); }, filterPeer: function(test) { test.expect(1); test.equal(matchdep.filterPeer('*', this.fixture).join(), 'peer-1,peer-2,peer-3', 'should find all peerDependencies matching "*"'); test.done(); }, filterAll: function(test) { test.expect(1); test.equal(matchdep.filterAll('*', this.fixture).join(), 'dep-1,dep-2,dep-3,dev-1,dev-2,dev-3,peer-1,peer-2,peer-3', 'should find everything matching "*"'); test.done(); }, 'wildcard support': function(test) { test.expect(3); test.equal(matchdep.filterAll('*', this.fixture).join(), 'dep-1,dep-2,dep-3,dev-1,dev-2,dev-3,peer-1,peer-2,peer-3', 'should find everything matching "*"'); test.equal(matchdep.filterAll('*-{1,3}', this.fixture).join(), 'dep-1,dep-3,dev-1,dev-3,peer-1,peer-3', 'should find everything matching "*-{1,3}"'); test.equal(matchdep.filterAll('', this.fixture).join(), '', 'should find nothing, since "" matches nothing'); test.done(); }, 'multiple pattern support': function(test) { test.expect(1); test.equal(matchdep.filterAll(['*','!micromatch']).join(), 'findup-sync,resolve,stack-trace,grunt,grunt-contrib-jshint,grunt-contrib-nodeunit', 'should find everything except micromatch'); test.done(); }, 'default to package.json': function(test) { test.expect(1); test.equal(matchdep.filter('*').join(), 'findup-sync,micromatch,resolve,stack-trace', 'should find all dependencies and devDependencies matching "*"'); test.done(); }, 'path is relative to calling module, not cwd': function(test) { test.expect(5); var submodule = require('./fixtures/submodule'); test.equal(submodule.defaultConfig().join(), 'pkg-1,pkg-2,pkg-3', 'should find all deps in package.json next to submodule'); test.equal(submodule.fileConfig().join(), 'pkg-1,pkg-2,pkg-3', 'should find all deps in package.json next to submodule'); test.equal(submodule.relativeConfig().join(), 'pkg-1,pkg-2,pkg-3', 'should find all deps in package.json next to submodule'); test.equal(submodule.relativeConfig2().join(), 'findup-sync,micromatch,resolve,stack-trace', 'should find all deps in ../../package.json from submodule'); test.equal(submodule.absoluteConfig().join(), 'pkg-1,pkg-2,pkg-3', 'should find all deps in package.json next to submodule'); test.done(); }, };