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

edp-core

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

edp-core - npm Package Compare versions

Comparing version 1.0.12 to 1.0.13

test/data/util/glob/a.js

65

lib/glob.js

@@ -23,3 +23,3 @@ /***************************************************************************

* new MyProcessor({
* fileset: [
* files: [
* 'dep/** /*.js',

@@ -34,3 +34,3 @@ * '!dep/esui/** /extension/*.js',

*
* @param {Array.<string>} patterns fileset的pattern.
* @param {Array.<string>} patterns files的pattern.
* @param {Array.<*>} allCandidates 所有的待选项.

@@ -108,9 +108,24 @@ * @param {(function(string, *):boolean)=} comparator 用来判断是否符合要求的函数,如果符合返回true.

* 支持exclude的写法,类似 edp.glob.filter
* @param {string|Array.<string>} patterns
* @param {string|Array.<string>} patterns 需要匹配的Pattern.
* @param {Object=} options 一些额外的配置.
*/
exports.sync = function( patterns ) {
exports.sync = function( patterns, options ) {
var glob = require( 'glob' );
var fs = require( 'fs' );
options = options || {};
var cwd = options.cwd || process.cwd();
function filter( candidates ) {
var path = require( 'path' );
return candidates.filter(function( item ){
var stat = fs.statSync( path.join( cwd, item ) );
return !stat.isDirectory();
});
}
var allCandidates = null;
if ( typeof patterns === 'string' ) {
return glob.sync( patterns );
allCandidates = glob.sync( patterns, options );
}

@@ -122,27 +137,29 @@ else if ( Array.isArray( patterns ) ) {

var allCandidates = glob.sync( patterns[ 0 ] );
if ( patterns.length === 1 ) {
return allCandidates;
}
for ( var i = 1; i < patterns.length; i ++ ) {
var pattern = patterns[ i ];
if ( pattern[ 0 ] === '!' ) {
pattern = pattern.substring( 1 );
var len = allCandidates.length;
while( len -- ) {
// edp.path.satisfy就是基于minimatch的
if ( path.satisfy( allCandidates[ len ], pattern ) ) {
allCandidates.splice( len, 1 );
var allCandidates = glob.sync( patterns[ 0 ], options );
if ( patterns.length > 1 ) {
for ( var i = 1; i < patterns.length; i ++ ) {
var pattern = patterns[ i ];
if ( pattern[ 0 ] === '!' ) {
pattern = pattern.substring( 1 );
var len = allCandidates.length;
while( len -- ) {
// edp.path.satisfy就是基于minimatch的
if ( path.satisfy( allCandidates[ len ], pattern ) ) {
allCandidates.splice( len, 1 );
}
}
}
else {
allCandidates.push.apply( allCandidates,
glob.sync( pattern, options ) );
}
}
else {
allCandidates.push.apply( allCandidates,
glob.sync( pattern ) );
}
}
}
return allCandidates;
if ( options.nodir === true ) {
return filter( allCandidates );
}
return allCandidates;
};

@@ -149,0 +166,0 @@

{
"name": "edp-core",
"version": "1.0.12",
"version": "1.0.13",
"description": "",

@@ -14,3 +14,3 @@ "main": "index.js",

"dependencies": {
"esprima": "~1.0.2",
"esprima": "~1.1.1",
"estraverse": "~1.5.0",

@@ -17,0 +17,0 @@ "minimatch": "~0.2.14",

@@ -18,2 +18,3 @@ /***************************************************************************

var glob = require( '../lib/glob' );
var path = require( 'path' );

@@ -47,2 +48,11 @@ var ALL_CANDIDATES = [

});
it( 'sync', function(){
var cwd = path.join( __dirname, 'data/util/glob' );
var options = { nodir: true, cwd: cwd };
expect( glob.sync( [ '*.js' ], options ) ).toEqual( [ 'a.js' ] );
expect( glob.sync( [ '**/*.js' ], options ) ).toEqual( [ 'a.js', 'b/b.js' ] );
expect( glob.sync( [ '**/b**' ], options ) ).toEqual( [ 'b/b.js' ] );
expect( glob.sync( [ '**/b*' ], { cwd: cwd } ) ).toEqual( [ 'b', 'b/b.js' ] );
});
});

@@ -49,0 +59,0 @@

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