package/package.json000644 000765 000024 0000001654 12656425273013037 0ustar00000000 000000 { "name": "matchdep", "description": "Use globule to filter npm module dependencies by name.", "version": "1.0.1", "homepage": "https://github.com/tkellen/node-matchdep", "author": { "name": "Tyler Kellen", "url": "http://goingslowly.com/" }, "repository": { "type": "git", "url": "git://github.com/tkellen/node-matchdep.git" }, "bugs": { "url": "https://github.com/tkellen/node-matchdep/issues" }, "license": "MIT", "main": "lib/matchdep", "engines": { "node": ">= 0.10.0" }, "scripts": { "test": "grunt" }, "dependencies": { "findup-sync": "~0.3.0", "micromatch": "^2.3.7", "resolve": "~1.1.6", "stack-trace": "0.0.9" }, "devDependencies": { "grunt": "~0.4.1", "grunt-contrib-jshint": "~0.11.3", "grunt-contrib-nodeunit": "~0.4.1" }, "keywords": [ "package.json", "dependencies", "devDependencies", "peerDependencies" ] } package/.npmignore000644 000765 000024 0000000021 12602053040012507 0ustar00000000 000000 test Gruntfile.jspackage/README.md000644 000765 000024 0000003455 12656425523012027 0ustar00000000 000000 # 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 * 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 package/LICENSE-MIT000644 000765 000024 0000002040 12602053040012147 0ustar00000000 000000 Copyright (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. package/.jshintrc000644 000765 000024 0000000345 12602053040012346 0ustar00000000 000000 { "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 } package/.travis.yml000644 000765 000024 0000000172 12656425266012656 0ustar00000000 000000 sudo: false language: node_js node_js: - "0.10" - "0.12" - "4" - "5" before_install: - npm install -g grunt-cli package/lib/matchdep.js000644 000765 000024 0000004475 12656425266013450 0ustar00000000 000000 /* * 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); }; });