first commit

This commit is contained in:
2026-09-08 20:28:54 +08:00
commit 2ada8d3d5a
37380 changed files with 4886169 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
{
"ignore": [
"**/node_modules/**",
"**/test/**"
],
"test": [
"test.js"
]
}
+18
View File
@@ -0,0 +1,18 @@
---
engines:
duplication:
enabled: true
config:
languages:
- javascript
checks:
Similar code:
enabled: false
exclude_fingerprints:
eslint:
enabled: true
fixme:
enabled: true
ratings:
paths:
- "**.js"
+1
View File
@@ -0,0 +1 @@
**/*{.,-}min.js
+213
View File
@@ -0,0 +1,213 @@
ecmaFeatures:
modules: true
jsx: true
env:
amd: true
browser: true
es6: true
jquery: true
node: true
# http://eslint.org/docs/rules/
rules:
# Possible Errors
comma-dangle: [2, never]
no-cond-assign: 2
no-console: 0
no-constant-condition: 2
no-control-regex: 2
no-debugger: 2
no-dupe-args: 2
no-dupe-keys: 2
no-duplicate-case: 2
no-empty: 2
no-empty-character-class: 2
no-ex-assign: 2
no-extra-boolean-cast: 2
no-extra-parens: 0
no-extra-semi: 2
no-func-assign: 2
no-inner-declarations: [2, functions]
no-invalid-regexp: 2
no-irregular-whitespace: 2
no-negated-in-lhs: 2
no-obj-calls: 2
no-regex-spaces: 2
no-sparse-arrays: 2
no-unexpected-multiline: 2
no-unreachable: 2
use-isnan: 2
valid-jsdoc: 0
valid-typeof: 2
# Best Practices
accessor-pairs: 2
block-scoped-var: 0
complexity: [2, 6]
consistent-return: 0
curly: 0
default-case: 0
dot-location: 0
dot-notation: 0
eqeqeq: 2
guard-for-in: 2
no-alert: 2
no-caller: 2
no-case-declarations: 2
no-div-regex: 2
no-else-return: 0
no-empty-label: 2
no-empty-pattern: 2
no-eq-null: 2
no-eval: 2
no-extend-native: 2
no-extra-bind: 2
no-fallthrough: 2
no-floating-decimal: 0
no-implicit-coercion: 0
no-implied-eval: 2
no-invalid-this: 0
no-iterator: 2
no-labels: 0
no-lone-blocks: 2
no-loop-func: 2
no-magic-number: 0
no-multi-spaces: 0
no-multi-str: 0
no-native-reassign: 2
no-new-func: 2
no-new-wrappers: 2
no-new: 2
no-octal-escape: 2
no-octal: 2
no-proto: 2
no-redeclare: 2
no-return-assign: 2
no-script-url: 2
no-self-compare: 2
no-sequences: 0
no-throw-literal: 0
no-unused-expressions: 2
no-useless-call: 2
no-useless-concat: 2
no-void: 2
no-warning-comments: 0
no-with: 2
radix: 2
vars-on-top: 0
wrap-iife: 2
yoda: 0
# Strict
strict: 0
# Variables
init-declarations: 0
no-catch-shadow: 2
no-delete-var: 2
no-label-var: 2
no-shadow-restricted-names: 2
no-shadow: 0
no-undef-init: 2
no-undef: 0
no-undefined: 0
no-unused-vars: 0
no-use-before-define: 0
# Node.js and CommonJS
callback-return: 2
global-require: 2
handle-callback-err: 2
no-mixed-requires: 0
no-new-require: 0
no-path-concat: 2
no-process-exit: 2
no-restricted-modules: 0
no-sync: 0
# Stylistic Issues
array-bracket-spacing: 0
block-spacing: 0
brace-style: 0
camelcase: 0
comma-spacing: 0
comma-style: 0
computed-property-spacing: 0
consistent-this: 0
eol-last: 0
func-names: 0
func-style: 0
id-length: 0
id-match: 0
indent: 0
jsx-quotes: 0
key-spacing: 0
linebreak-style: 0
lines-around-comment: 0
max-depth: 0
max-len: 0
max-nested-callbacks: 0
max-params: 0
max-statements: [2, 30]
new-cap: 0
new-parens: 0
newline-after-var: 0
no-array-constructor: 0
no-bitwise: 0
no-continue: 0
no-inline-comments: 0
no-lonely-if: 0
no-mixed-spaces-and-tabs: 0
no-multiple-empty-lines: 0
no-negated-condition: 0
no-nested-ternary: 0
no-new-object: 0
no-plusplus: 0
no-restricted-syntax: 0
no-spaced-func: 0
no-ternary: 0
no-trailing-spaces: 0
no-underscore-dangle: 0
no-unneeded-ternary: 0
object-curly-spacing: 0
one-var: 0
operator-assignment: 0
operator-linebreak: 0
padded-blocks: 0
quote-props: 0
quotes: 0
require-jsdoc: 0
semi-spacing: 0
semi: 0
sort-vars: 0
space-after-keywords: 0
space-before-blocks: 0
space-before-function-paren: 0
space-before-keywords: 0
space-in-parens: 0
space-infix-ops: 0
space-return-throw-case: 0
space-unary-ops: 0
spaced-comment: 0
wrap-regex: 0
# ECMAScript 6
arrow-body-style: 0
arrow-parens: 0
arrow-spacing: 0
constructor-super: 0
generator-star-spacing: 0
no-arrow-condition: 0
no-class-assign: 0
no-const-assign: 0
no-dupe-class-members: 0
no-this-before-super: 0
no-var: 0
object-shorthand: 0
prefer-arrow-callback: 0
prefer-const: 0
prefer-reflect: 0
prefer-spread: 0
prefer-template: 0
require-yield: 0
+33
View File
@@ -0,0 +1,33 @@
# Logs
logs
*.log
npm-debug.log*
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
node_modules
# Optional npm cache directory
.npm
# Optional REPL history
.node_repl_history
+9
View File
@@ -0,0 +1,9 @@
sudo: false
language: node_js
node_js:
- "0.10"
- "0.12"
- "4"
- "5"
after_script:
- npm run coveralls
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Sven Schoenung
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.
+48
View File
@@ -0,0 +1,48 @@
[![npm Version](https://img.shields.io/npm/v/glob-escape.svg)](https://www.npmjs.com/package/glob-escape)
[![Build Status](https://travis-ci.org/svenschoenung/glob-escape.svg?branch=master)](https://travis-ci.org/svenschoenung/glob-escape)
[![Coverage Status](https://coveralls.io/repos/github/svenschoenung/glob-escape/badge.svg?branch=master)](https://coveralls.io/github/svenschoenung/glob-escape?branch=master)
[![Dependency Status](https://david-dm.org/svenschoenung/glob-escape.svg)](https://david-dm.org/svenschoenung/glob-escape)
[![devDependency Status](https://david-dm.org/svenschoenung/glob-escape/dev-status.svg)](https://david-dm.org/svenschoenung/glob-escape#info=devDependencies)
[![Code Climate](https://codeclimate.com/github/svenschoenung/glob-escape/badges/gpa.svg)](https://codeclimate.com/github/svenschoenung/glob-escape)
[![Codacy Badge](https://api.codacy.com/project/badge/grade/dee709366a3245268e25a81e6a124ce6)](https://www.codacy.com/app/svenschoenung/glob-escape)
# glob-escape
Escapes glob patterns. Works for packages like [`minimatch`](https://www.npmjs.com/package/minimatch), [`multimatch`](https://www.npmjs.com/package/multimatch), [`glob`](https://www.npmjs.com/package/glob), [`glob-stream`](https://www.npmjs.com/package/glob-stream), [`globby`](https://www.npmjs.com/package/globby), [`vinyl-fs`](https://www.npmjs.com/package/vinyl-fs) and [`gulp`](https://www.npmjs.com/package/gulp`).
## Installation
npm install glob-escape
## Usage
```js
var escapeGlob = require('glob-escape');
var glob = require('glob');
glob('algorithms/a*.txt', function(err, array) {
// array might contain several files like:
// - algorithms/a*.txt
// - algorithms/alpha-beta_pruning.txt
// - algorithms/augmented_lagrangian_method.txt
});
glob(escapeGlob('algorithms/a*.txt'), function(err, array) {
// array will only contain one file:
// - algorithms/a*.txt
});
```
## API
### escapeGlob(glob)
Escapes all glob patterns in the provided `glob`.
`glob` may be a string or an array of strings.
Returns the escaped glob.
## License
[MIT](LICENSE)
+29
View File
@@ -0,0 +1,29 @@
var util = require('util');
function escapeGlobStringOrArray(escapeFn) {
return function(glob) {
if (typeof glob === 'string') {
return escapeFn(glob);
}
if (Array.isArray(glob)) {
return glob.map(escapeFn);
}
throw new Error('glob pattern needs to be a string or array');
};
}
function escapeGlob(glob) {
return glob
.replace(/\\/g, '\\\\')
.replace(/\*/g, '\\*')
.replace(/\?/g, '\\?')
.replace(/\[/g, '\\[')
.replace(/\]/g, '\\]')
.replace(/\{/g, '\\{')
.replace(/\}/g, '\\}')
.replace(/\)/g, '\\)')
.replace(/\(/g, '\\(')
.replace(/\!/g, '\\!');
}
module.exports = escapeGlobStringOrArray(escapeGlob);
+48
View File
@@ -0,0 +1,48 @@
{
"name": "glob-escape",
"description": "Escape glob patterns",
"version": "0.0.2",
"author": {
"name": "Sven Schönung <sven.schoenung@gmail.com> (http://sven.schoenung.org/)"
},
"homepage": "https://github.com/svenschoenung/glob-escape.git",
"repository": {
"type": "git",
"url": "git://github.com/svenschoenung/glob-escape.git"
},
"engines": {
"node": ">= 0.10"
},
"dependencies": {
},
"devDependencies": {
"chai": "^3.5.0",
"codacy-coverage": "^1.1.3",
"coveralls": "^2.11.6",
"istanbul": "^0.4.2",
"minimatch": "^3.0.2",
"mocha": "^2.2.4",
"mocha-lcov-reporter": "^1.0.0"
},
"scripts": {
"test": "istanbul cover ./node_modules/mocha/bin/_mocha test.js -x test.js --report html -- -R spec",
"coveralls": "istanbul cover ./node_modules/mocha/bin/_mocha test.js -x test.js --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"codacy": "istanbul cover ./node_modules/mocha/bin/_mocha test.js -x test.js --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/.bin/codacy-coverage && rm -rf ./coverage"
},
"keywords": [
"backslash",
"escape",
"glob",
"globbing",
"globs",
"gulpfriendly",
"match",
"matcher",
"minimatch",
"pattern",
"patterns",
"wildcard",
"wildcards"
],
"license": "MIT"
}
+218
View File
@@ -0,0 +1,218 @@
'use strict';
/* global describe:false, it:false */
var chai = require('chai');
var assert = chai.assert;
var expect = chai.expect;
var esc = require('./index.js');
var minimatch = require('minimatch');
var shouldMatch = function(file, pattern) {
var matches = minimatch(file, pattern)
if (!matches) {
var msg = '"' + pattern + '" doesn\'t match "' + file + '"';
assert.fail(matches, true, msg);
}
};
var shouldNotMatch = function(file, pattern) {
var matches = minimatch(file, pattern)
if (matches) {
var msg = '"' + pattern + '" matches "' + file + '"'
fail(matches, false, msg);
}
};
describe('escapeGlob', function() {
it('should fail if pattern is not a string or array', function() {
expect(esc).to.throw(Error);
expect(esc.bind(null)).to.throw(Error);
expect(esc.bind(0)).to.throw(Error);
expect(esc.bind({})).to.throw(Error);
expect(esc.bind(/regex/)).to.throw(Error);
});
it('should escape *', function() {
shouldMatch('f*', esc('f*'));
shouldMatch('f', 'f*');
shouldNotMatch('f', esc('f*'));
shouldMatch('f*.txt', 'f*');
shouldNotMatch('f*.txt', esc('f*'));
shouldMatch('file.txt', 'f*');
shouldNotMatch('file.txt', esc('f*'));
shouldMatch('f*ile*', esc('f*ile*'));
shouldMatch('f*ile', 'f*ile*');
shouldNotMatch('f*ile', esc('f*ile*'));
shouldMatch('f*ile*.txt', 'f*ile*');
shouldNotMatch('f*ile*.txt', esc('f*ile*'));
shouldMatch('f*ile.txt', 'f*ile*');
shouldNotMatch('f*ile.txt', esc('f*ile*'));
});
it('should escape **', function() {
shouldMatch('**/f', esc('**/f'));
shouldMatch('f', '**/f');
shouldNotMatch('f', esc('**/f'));
shouldMatch('dir/f', '**/f');
shouldNotMatch('dir/f', esc('**/f'));
shouldMatch('dir/**/f', 'dir/**/f');
shouldMatch('dir/f', 'dir/**/f');
shouldNotMatch('dir/f', esc('dir/**/f'));
shouldMatch('dir/dir/f', 'dir/**/f');
shouldNotMatch('dir/dir/f', esc('dir/**/f'));
shouldMatch('**/dir/**/f', '**/dir/**/f');
shouldMatch('dir/f', '**/dir/**/f');
shouldNotMatch('dir/f', esc('**/dir/**/f'));
shouldMatch('dir/dir/f', '**/dir/**/f');
shouldNotMatch('dir/dir/f', esc('**/dir/**/f'));
shouldMatch('dir/dir/f', '**/dir/**/f');
shouldNotMatch('dir/dir/dir/f', esc('**/dir/**/f'));
});
it('should escape ?', function() {
shouldMatch('f?', esc('f?'));
shouldMatch('fa', 'f?');
shouldNotMatch('fa', esc('f?'));
shouldMatch('f?l?', esc('f?l?'));
shouldMatch('file', 'f?l?');
shouldNotMatch('file', esc('f?l?'));
});
it('should escape { }', function() {
shouldMatch('f{a,b}{a,b}', esc('f{a,b}{a,b}'));
shouldMatch('faa', 'f{a,b}{a,b}');
shouldNotMatch('faa', esc('f{a,b}{a,b}'));
shouldMatch('fab', 'f{a,b}{a,b}');
shouldNotMatch('fab', esc('f{a,b}{a,b}'));
shouldMatch('fba', 'f{a,b}{a,b}');
shouldNotMatch('fba', esc('f{a,b}{a,b}'));
shouldMatch('fbb', 'f{a,b}{a,b}');
shouldNotMatch('fbb', esc('f{a,b}{a,b}'));
shouldMatch('f{1..3}', esc('f{1..3}'));
shouldMatch('f1', 'f{1..3}');
shouldNotMatch('f1', esc('f{1..3}'));
shouldMatch('f2', 'f{1..3}');
shouldNotMatch('f2', esc('f{1..3}'));
shouldMatch('f3', 'f{1..3}');
shouldNotMatch('f3', esc('f{1..3}'));
});
it('should escape [ ]', function() {
shouldMatch('f[ab][ab]', esc('f[ab][ab]'));
shouldMatch('faa', 'f[ab][ab]');
shouldNotMatch('faa', esc('f[ab][ab]'));
shouldMatch('fab', 'f[ab][ab]');
shouldNotMatch('fab', esc('f[ab][ab]'));
shouldMatch('fba', 'f[ab][ab]');
shouldNotMatch('fba', esc('f[ab][ab]'));
shouldMatch('fbb', 'f[ab][ab]');
shouldNotMatch('fbb', esc('f[ab][ab]'));
});
it('should escape !( | )', function() {
shouldMatch('f!(a|b)!(a|b)', esc('f!(a|b)!(a|b)'));
shouldMatch('fcc', 'f!(a|b)!(a|b)');
shouldNotMatch('fcc', esc('f!(a|b)!(a|b)'));
});
it('should escape ?( | )', function() {
shouldMatch('f?(a|b)?(a|b)', esc('f?(a|b)?(a|b)'));
shouldMatch('fa', 'f?(a|b)?(a|b)');
shouldNotMatch('fa', esc('f?(a|b)?(a|b)'));
shouldMatch('fb', 'f?(a|b)?(a|b)');
shouldNotMatch('fb', esc('f?(a|b)?(a|b)'));
shouldMatch('faa', 'f?(a|b)?(a|b)');
shouldNotMatch('faa', esc('f?(a|b)?(a|b)'));
shouldMatch('fab', 'f?(a|b)?(a|b)');
shouldNotMatch('fab', esc('f?(a|b)?(a|b)'));
shouldMatch('fba', 'f?(a|b)?(a|b)');
shouldNotMatch('fba', esc('f?(a|b)?(a|b)'));
shouldMatch('fbb', 'f?(a|b)?(a|b)');
shouldNotMatch('fbb', esc('f?(a|b)?(a|b)'));
});
it('should escape +( | )', function() {
shouldMatch('f+(a|b)', esc('f+(a|b)'));
shouldMatch('fa', 'f+(a|b)');
shouldNotMatch('fa', esc('f+(a|b)'));
shouldMatch('fb', 'f+(a|b)');
shouldNotMatch('fb', esc('f+(a|b)'));
shouldMatch('faa', 'f+(a|b)');
shouldNotMatch('faa', esc('f+(a|b)'));
shouldMatch('fab', 'f+(a|b)');
shouldNotMatch('fab', esc('f+(a|b)'));
shouldMatch('fba', 'f+(a|b)');
shouldNotMatch('fba', esc('f+(a|b)'));
shouldMatch('fbb', 'f+(a|b)');
shouldNotMatch('fbb', esc('f+(a|b)'));
});
it('should escape *( | )', function() {
shouldMatch('f*(a|b)', esc('f*(a|b)'));
shouldMatch('f', 'f*(a|b)');
shouldNotMatch('f', esc('f*(a|b)'));
shouldMatch('fa', 'f*(a|b)');
shouldNotMatch('fa', esc('f*(a|b)'));
shouldMatch('fb', 'f*(a|b)');
shouldNotMatch('fb', esc('f*(a|b)'));
shouldMatch('faa', 'f*(a|b)');
shouldNotMatch('faa', esc('f*(a|b)'));
shouldMatch('fab', 'f*(a|b)');
shouldNotMatch('fab', esc('f*(a|b)'));
shouldMatch('fba', 'f*(a|b)');
shouldNotMatch('fba', esc('f*(a|b)'));
shouldMatch('fbb', 'f*(a|b)');
shouldNotMatch('fbb', esc('f*(a|b)'));
});
it('should escape @( | )', function() {
shouldMatch('f@(ab|ba)', esc('f@(ab|ba)'));
shouldMatch('fab', 'f@(ab|ba)');
shouldNotMatch('fab', esc('f@(ab|ba)'));
shouldMatch('fba', 'f@(ab|ba)');
shouldNotMatch('fbb', esc('f@(ab|ba)'));
});
it('should escape !', function() {
shouldMatch('!f', esc('!f'));
shouldMatch('x', '!f');
shouldNotMatch('x', esc('!f'));
});
it('should escape \\', function() {
shouldMatch('f\\x', esc('f\\x'));
shouldMatch('fx', 'f\\x');
shouldNotMatch('fx', esc('f\\x'));
});
it('should escape arrays', function() {
var pattern = [
'f*',
'f*ile*',
'f?l?',
'**/f',
'dir/**/f',
'**/dir/**/f',
'f{a,b}{a,b}',
'f{1..3}',
'f[ab][ab]',
'f!(a|b)!(a|b)',
'f?(a|b)?(a|b)',
'f+(a|b)',
'f*(a|b)',
'f@(ab|ba)'
];
expect(esc(pattern)).to.eql(pattern.map(esc));
});
});