Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ignorefs

Package Overview
Dependencies
Maintainers
1
Versions
138
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ignorefs - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

.flowconfig

97

es2015/index.js

@@ -0,63 +1,66 @@

/* @flow */
'use strict';
// Import
var pathUtil = require('path');
var ignorePatterns = require('ignorepatterns');
var ignorePatterns /* :RegExp */ = require('ignorepatterns');
// Is Ignored Path
// opts={ignorePaths, ignoreHiddenFiles, ignoreCommonPatterns, ignoreCustomPatterns}
// returns true/false
function isIgnoredPath(path, opts) {
/* ::
type IgnoreOpts = {
ignorePaths?: false | Array<string>,
ignoreHiddenFiles?: boolean,
ignoreCommonPatterns?: boolean | RegExp,
ignoreCustomPatterns?: false | RegExp
}
*/
/**
Is Ignored Path
Check to see if a path, either a full path or basename, should be ignored
@param {string} path - a full path or basename of a file or directory
@param {object} [opts] - configurations options
@param {false | Array<string>} [opts.ignorePaths] - an optional listing of full paths to ignore
@param {boolean} [opts.ignoreHiddenFiles] - whether or not to ignore basenames beginning with a "." character
@param {boolean} [opts.ignoreCommonPatterns] - if true, will check the path and basename of the path against https://github.com/bevry/ignorepatterns
@param {false | RegExp} [opts.ignoreCustomPatterns] - if a regular expression, will test the regular expression against the path and basename of the path
@returns {boolean} whether or not the path should be ignored
*/
function isIgnoredPath(path /* :string */) {
var opts /* :IgnoreOpts */ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
// Prepare
var result = false;
var basename = pathUtil.basename(path);
// Defaults
if (!opts) opts = {};
if (opts.ignorePaths == null) opts.ignorePaths = false;
if (opts.ignoreHiddenFiles == null) opts.ignoreHiddenFiles = false;
if (opts.ignoreCommonPatterns == null) opts.ignoreCommonPatterns = true;
if (opts.ignoreCustomPatterns == null) opts.ignoreCustomPatterns = false;
// Test Paths
if (opts.ignorePaths) {
for (var i = 0; i < opts.ignorePaths.length; ++i) {
var ignorePath = opts.ignorePaths[i];
if (path.indexOf(ignorePath) === 0) {
return true;
}
}
}
// Fetch the common patterns to ignore
if (opts.ignoreCommonPatterns === true) {
opts.ignoreCommonPatterns = ignorePatterns;
// Test Hidden Files
if (opts.ignoreHiddenFiles && basename[0] === '.') {
return true;
}
// Test Ignore Paths
if (opts.ignorePaths) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
// Test Common Patterns
if (opts.ignoreCommonPatterns == null || opts.ignoreCommonPatterns === true) {
return ignorePatterns.test(path) || path !== basename && ignorePatterns.test(basename);
} else if (opts.ignoreCommonPatterns) {
var ignoreCommonPatterns /* :RegExp */ = opts.ignoreCommonPatterns;
return ignoreCommonPatterns.test(path) || path !== basename && ignoreCommonPatterns.test(basename);
}
try {
for (var _iterator = opts.ignorePaths[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var ignorePath = _step.value;
if (path.indexOf(ignorePath) === 0) {
result = true;
break;
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
// Test Custom Patterns
if (opts.ignoreCustomPatterns) {
var ignoreCustomPatterns /* :RegExp */ = opts.ignoreCustomPatterns;
return ignoreCustomPatterns.test(path) || path !== basename && ignoreCustomPatterns.test(basename);
}
// Test Ignore Patterns
result = result || opts.ignoreHiddenFiles && /^\./.test(basename) || opts.ignoreCommonPatterns && opts.ignoreCommonPatterns.test(basename) || opts.ignoreCommonPatterns && opts.ignoreCommonPatterns.test(path) || opts.ignoreCustomPatterns && opts.ignoreCustomPatterns.test(basename) || opts.ignoreCustomPatterns && opts.ignoreCustomPatterns.test(path) || false;
// Return
return result;
return false;
}

@@ -64,0 +67,0 @@

# History
## v1.2.0 2016 November 6
- Rejigged internals, functionality should remain exactly the same
- Documentation is now generated from source code
- Added Flow Type Comments
- More efficient evaluation of ignore checks
## v1.1.1 2016 May 2

@@ -4,0 +10,0 @@ - Fixed `browser` field

{
"title": "IgnoreFS",
"name": "ignorefs",
"version": "1.1.1",
"version": "1.2.0",
"description": "Ignore common and custom patterns of the file system",

@@ -44,4 +44,3 @@ "homepage": "https://github.com/bevry/ignorefs",

"contributors": [
"Benjamin Lupton <b@lupton.cc> (http://balupton.com)",
"Benjamin Lupton (https://balupton.com)"
"Benjamin Lupton <b@lupton.cc> (http://balupton.com)"
],

@@ -60,4 +59,4 @@ "bugs": {

{
"description": "Source + ESNext + Require",
"entry": "source/index.js",
"description": "Source + ESNext + Require + Flow Type Comments",
"entry": "index.js",
"directory": "source",

@@ -69,3 +68,5 @@ "syntaxes": [

"const",
"let"
"let",
"destructuring",
"defaults"
]

@@ -75,3 +76,3 @@ },

"description": "Babel Compiled + ES2015 + Require",
"entry": "es2015/index.js",
"entry": "index.js",
"directory": "es2015",

@@ -88,31 +89,35 @@ "syntaxes": [

"scripts": {
"setup": "npm install",
"clean": "rm -Rf ./docs ./es2015",
"compile": "npm run compile:es2015",
"compile:es2015": "babel ./source --out-dir ./es2015 --presets es2015",
"meta": "npm run meta:projectz",
"meta:projectz": "projectz compile",
"prepare": "npm run compile && npm run test && npm run meta",
"release": "npm run prepare && npm run release:publish && npm run release:tag && npm run release:push",
"release:publish": "npm publish",
"release:tag": "git tag v$npm_package_version -a",
"release:push": "git push origin master && git push origin --tags",
"pretest": "npm run test:eslint",
"test:eslint": "eslint ./source",
"test": "node --harmony -e \"require('editions').requirePackage(process.cwd(), require, 'test.js')\""
"our:setup": "npm install",
"our:clean": "rm -Rf ./docs ./es2015",
"our:compile": "npm run our:compile:es2015",
"our:compile:es2015": "babel ./source --out-dir ./es2015 --presets es2015",
"our:meta": "npm run our:meta:docs && npm run our:meta:projectz",
"our:meta:docs": "documentation build -f html -o ./docs -g --shallow ./source/**.js",
"our:meta:projectz": "projectz compile",
"our:verify": "npm run our:verify:eslint && npm run our:verify:flow",
"our:verify:eslint": "eslint --fix ./source",
"our:verify:flow": "flow check",
"our:test": "npm run our:verify && npm test",
"our:release": "npm run our:release:prepare && npm run our:release:publish && npm run our:release:tag && npm run our:release:push",
"our:release:prepare": "npm run our:clean && npm run our:compile && npm run our:test && npm run our:meta",
"our:release:publish": "npm publish",
"our:release:tag": "git tag v$npm_package_version -a",
"our:release:push": "git push origin master && git push origin --tags",
"test": "node --harmony ./test.js --joe-reporter=console"
},
"dependencies": {
"editions": "^1.1.1",
"ignorepatterns": "^1.0.1"
"editions": "^1.3.3",
"ignorepatterns": "^1.1.0"
},
"devDependencies": {
"assert-helpers": "^4.1.0",
"babel-cli": "^6.7.7",
"babel-preset-es2015": "^6.6.0",
"eslint": "^2.9.0",
"eslint-plugin-babel": "^3.2.0",
"joe": "^1.6.0",
"joe-reporter-console": "^1.2.1",
"projectz": "^1.1.4"
"assert-helpers": "^4.4.0",
"babel-cli": "^6.18.0",
"babel-preset-es2015": "^6.18.0",
"documentation": "^4.0.0-beta12",
"eslint": "^3.9.1",
"flow-bin": "^0.34.0",
"joe": "^2.0.2",
"joe-reporter-console": "^2.0.1",
"projectz": "^1.3.2"
}
}

@@ -45,3 +45,3 @@ <!-- TITLE/ -->

<li>Module: <code>require('ignorefs')</code></li>
<li>CDN URL: <code>//wzrd.in/bundle/ignorefs@1.1.1</code></li></ul>
<li>CDN URL: <code>//wzrd.in/bundle/ignorefs@1.2.0</code></li></ul>

@@ -57,3 +57,3 @@ <a href="http://enderjs.com" title="Ender is a full featured package manager for your browser"><h3>Ender</h3></a><ul>

<ul><li><code>ignorefs</code> aliases <code>ignorefs/index.js</code> which uses <a href="https://github.com/bevry/editions" title="Editions are the best way to produce and consume packages you care about.">Editions</a> to automatically select the correct edition for the consumers environment</li>
<li><code>ignorefs/source/index.js</code> is Source + <a href="https://babeljs.io/docs/learn-es2015/" title="ECMAScript Next">ESNext</a> + <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a></li>
<li><code>ignorefs/source/index.js</code> is Source + <a href="https://babeljs.io/docs/learn-es2015/" title="ECMAScript Next">ESNext</a> + <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a> + <a href="http://flowtype.org/blog/2015/02/20/Flow-Comments.html" title="Flow is a static type checker for JavaScript">Flow Type Comments</a></li>
<li><code>ignorefs/es2015/index.js</code> is <a href="https://babeljs.io" title="The compiler for writing next generation JavaScript">Babel</a> Compiled + <a href="http://babeljs.io/docs/plugins/preset-es2015/" title="ECMAScript 2015">ES2015</a> + <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a></li></ul>

@@ -68,11 +68,3 @@

``` javascript
var isIgnored = require('ignorefs').isIgnoredPath(path, {
ignorePaths: false, // array of paths to ignore
ignoreHiddenFiles: false, // whether or not we should ignore files that start with a dot
ignoreCommonPatterns: true, // whether or not we should common patterns like "thumbs.db" etc, uses https://github.com/bevry/ignorepatterns
ignoreCustomPatterns: false, // can be a regex that is tested against the basename of the file and the file's path
});
console.log(isIgnored); // true or false
```
[API Documentation](http://rawgit.com/bevry/ignorefs/master/docs/index.html)

@@ -106,3 +98,3 @@

<ul><li><a href="http://balupton.com">Benjamin Lupton</a></li></ul>
<ul><li><a href="http://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/ignorefs/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/ignorefs">view contributions</a></li></ul>

@@ -124,4 +116,3 @@ <h3>Sponsors</h3>

<ul><li><a href="http://balupton.com">Benjamin Lupton</a></li>
<li><a href="https://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/ignorefs/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/ignorefs">view contributions</a></li></ul>
<ul><li><a href="http://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/ignorefs/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/ignorefs">view contributions</a></li></ul>

@@ -128,0 +119,0 @@ <a href="https://github.com/bevry/ignorefs/blob/master/CONTRIBUTING.md#files">Discover how you can contribute by heading on over to the <code>CONTRIBUTING.md</code> file.</a>

@@ -0,31 +1,38 @@

/* @flow */
'use strict'
// Import
const pathUtil = require('path')
const ignorePatterns = require('ignorepatterns')
const ignorePatterns /* :RegExp */ = require('ignorepatterns')
// Is Ignored Path
// opts={ignorePaths, ignoreHiddenFiles, ignoreCommonPatterns, ignoreCustomPatterns}
// returns true/false
function isIgnoredPath (path, opts) {
/* ::
type IgnoreOpts = {
ignorePaths?: false | Array<string>,
ignoreHiddenFiles?: boolean,
ignoreCommonPatterns?: boolean | RegExp,
ignoreCustomPatterns?: false | RegExp
}
*/
/**
Is Ignored Path
Check to see if a path, either a full path or basename, should be ignored
@param {string} path - a full path or basename of a file or directory
@param {object} [opts] - configurations options
@param {false | Array<string>} [opts.ignorePaths] - an optional listing of full paths to ignore
@param {boolean} [opts.ignoreHiddenFiles] - whether or not to ignore basenames beginning with a "." character
@param {boolean} [opts.ignoreCommonPatterns] - if true, will check the path and basename of the path against https://github.com/bevry/ignorepatterns
@param {false | RegExp} [opts.ignoreCustomPatterns] - if a regular expression, will test the regular expression against the path and basename of the path
@returns {boolean} whether or not the path should be ignored
*/
function isIgnoredPath (path /* :string */, opts /* :IgnoreOpts */ = {}) {
// Prepare
let result = false
const basename = pathUtil.basename(path)
// Defaults
if ( !opts ) opts = {}
if ( opts.ignorePaths == null ) opts.ignorePaths = false
if ( opts.ignoreHiddenFiles == null ) opts.ignoreHiddenFiles = false
if ( opts.ignoreCommonPatterns == null ) opts.ignoreCommonPatterns = true
if ( opts.ignoreCustomPatterns == null ) opts.ignoreCustomPatterns = false
// Fetch the common patterns to ignore
if ( opts.ignoreCommonPatterns === true ) {
opts.ignoreCommonPatterns = ignorePatterns
}
// Test Ignore Paths
// Test Paths
if ( opts.ignorePaths ) {
for ( const ignorePath of opts.ignorePaths ) {
for ( let i = 0; i < opts.ignorePaths.length; ++i ) {
const ignorePath = opts.ignorePaths[i]
if ( path.indexOf(ignorePath) === 0 ) {
result = true
break
return true
}

@@ -35,14 +42,30 @@ }

// Test Ignore Patterns
result =
result ||
(opts.ignoreHiddenFiles && (/^\./).test(basename)) ||
(opts.ignoreCommonPatterns && opts.ignoreCommonPatterns.test(basename)) ||
(opts.ignoreCommonPatterns && opts.ignoreCommonPatterns.test(path)) ||
(opts.ignoreCustomPatterns && opts.ignoreCustomPatterns.test(basename)) ||
(opts.ignoreCustomPatterns && opts.ignoreCustomPatterns.test(path)) ||
false
// Test Hidden Files
if ( opts.ignoreHiddenFiles && basename[0] === '.' ) {
return true
}
// Test Common Patterns
if ( opts.ignoreCommonPatterns == null || opts.ignoreCommonPatterns === true ) {
return ignorePatterns.test(path) || (
path !== basename && ignorePatterns.test(basename)
)
}
else if ( opts.ignoreCommonPatterns ) {
const ignoreCommonPatterns /* :RegExp */ = opts.ignoreCommonPatterns
return ignoreCommonPatterns.test(path) || (
path !== basename && ignoreCommonPatterns.test(basename)
)
}
// Test Custom Patterns
if ( opts.ignoreCustomPatterns ) {
const ignoreCustomPatterns /* :RegExp */ = opts.ignoreCustomPatterns
return ignoreCustomPatterns.test(path) || (
path !== basename && ignoreCustomPatterns.test(basename)
)
}
// Return
return result
return false
}

@@ -49,0 +72,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc