Added some tests

This commit is contained in:
2021-06-23 22:30:45 +02:00
parent 24f897e907
commit 3d3d7fae48
3796 changed files with 218744 additions and 3 deletions

26
tests/node_modules/dotignore/.eslintrc generated vendored Normal file
View File

@@ -0,0 +1,26 @@
{
"root": true,
"extends": "@ljharb",
"rules": {
"func-name-matching": [2, "always"],
"func-style": 1,
"indent": [2, 2],
"max-statements": 0,
"no-loop-func": 1,
"no-param-reassign": 1,
},
"overrides": [
{
"files": "bin/**",
"env": {
"node": true,
},
"rules": {
"no-console": 0,
},
},
],
}

26
tests/node_modules/dotignore/README.md generated vendored Normal file
View File

@@ -0,0 +1,26 @@
# dotignore
## `ignored $IGNOREFILE`
Check the ignorefile against the current directory.
Print out if a file should be ignored by prefixing with a `-`.
If the file should not be ignored prefix it with a `+`.
## API
### exports.createMatcher(str)
Return a `Matcher` that fully matches the `str` argument.
`str` should conform to the `.gitignore` specification.
### Matcher.shouldIgnore(name)
Test that all the rules provided to create the matcher match the name given.
`/` is expected as the path delimiter.
Returns `true` if the name should be ignored.
## LICENSE
MIT

23
tests/node_modules/dotignore/bin/ignored generated vendored Executable file
View File

@@ -0,0 +1,23 @@
#!/usr/bin/env node
'use strict';
var fs = require('fs');
var path = require('path');
var rules = String(fs.readFileSync(process.argv[2] || '.gitignore'));
var matcher = require('../').createMatcher(rules);
function checkDir(dir) {
fs.readdirSync(dir).forEach(function (filename) {
var resolved = path.join(dir, filename);
if (matcher.shouldIgnore(resolved)) {
console.log('- ' + resolved);
} else if (fs.statSync(resolved).isDirectory()) {
checkDir(resolved);
} else {
console.log('+ ' + resolved);
}
});
}
checkDir('.');

53
tests/node_modules/dotignore/index.js generated vendored Normal file
View File

@@ -0,0 +1,53 @@
'use strict';
var minimatch = require('minimatch');
var path = require('path');
function IgnoreMatcher(str) {
var negated = [];
this.negated = negated;
var rooted = [];
this.rooted = rooted;
this.matchers = str.split(/\r?\n|\r/).map(function (line) {
var negatedLine = line[0] === '!';
var commentLine = line[0] === '#';
var rootedLine = line[0] === '/';
if (negatedLine || commentLine || rootedLine) {
line = line.slice(1);
}
var emptyLine = line === '';
if (emptyLine) {
return null;
}
var isShellGlob = line.indexOf('/') >= 0;
negated[negated.length] = negatedLine;
rooted[rooted.length] = rootedLine || isShellGlob;
return minimatch.makeRe(line, {
comment: commentLine,
empty: emptyLine,
matchBase: !rootedLine,
negated: true // negated
});
}).filter(Boolean);
return this;
}
IgnoreMatcher.prototype.delimiter = path.sep;
IgnoreMatcher.prototype.shouldIgnore = function (filename) {
var isMatching = false;
for (var i = 0; i < this.matchers.length; i++) {
var matcher = this.matchers[i];
if (this.rooted[i]) {
if (matcher.test(filename)) {
isMatching = !this.negated[i];
}
} else if (filename.split(this.delimiter).some(function (part) {
return matcher.test(part);
})) {
isMatching = !this.negated[i];
}
}
return isMatching;
};
exports.createMatcher = function (ignoreFileStr) {
return new IgnoreMatcher(ignoreFileStr);
};

70
tests/node_modules/dotignore/package.json generated vendored Normal file
View File

@@ -0,0 +1,70 @@
{
"_from": "dotignore@^0.1.2",
"_id": "dotignore@0.1.2",
"_inBundle": false,
"_integrity": "sha512-UGGGWfSauusaVJC+8fgV+NVvBXkCTmVv7sk6nojDZZvuOUNGUy0Zk4UpHQD6EDjS0jpBwcACvH4eofvyzBcRDw==",
"_location": "/dotignore",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "dotignore@^0.1.2",
"name": "dotignore",
"escapedName": "dotignore",
"rawSpec": "^0.1.2",
"saveSpec": null,
"fetchSpec": "^0.1.2"
},
"_requiredBy": [
"/tape"
],
"_resolved": "https://registry.npmjs.org/dotignore/-/dotignore-0.1.2.tgz",
"_shasum": "f942f2200d28c3a76fbdd6f0ee9f3257c8a2e905",
"_spec": "dotignore@^0.1.2",
"_where": "/home/lilleman/go/src/gitlab.larvit.se/power-plan/auth/tests/node_modules/tape",
"author": {
"name": "bradleymeck"
},
"bin": {
"ignored": "bin/ignored"
},
"bugs": {
"url": "https://github.com/bmeck/dotignore/issues"
},
"bundleDependencies": false,
"dependencies": {
"minimatch": "^3.0.4"
},
"deprecated": false,
"description": "ignorefile/includefile matching .gitignore spec",
"devDependencies": {
"@ljharb/eslint-config": "^15.1.0",
"covert": "^1.1.1",
"eslint": "^6.8.0",
"safe-publish-latest": "^1.1.4",
"tape": "^4.12.1"
},
"homepage": "https://github.com/bmeck/dotignore#readme",
"keywords": [
"ignore",
"gitignore",
"npmignore",
"glob",
"pattern"
],
"license": "MIT",
"main": "index.js",
"name": "dotignore",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/bmeck/dotignore.git"
},
"scripts": {
"coverage": "covert test/index.js",
"lint": "eslint bin/* .",
"prepublish": "safe-publish-latest",
"pretest": "npm run lint",
"test": "node test && npm run coverage -- --quiet"
},
"version": "0.1.2"
}

2
tests/node_modules/dotignore/test/.1-ignore generated vendored Normal file
View File

@@ -0,0 +1,2 @@
*ignored
!a/not*

7
tests/node_modules/dotignore/test/1-expected generated vendored Normal file
View File

@@ -0,0 +1,7 @@
+ .ignore
- a/a/notignored
- a/ignored
+ a/notignored
+ a/notlisted
+ expected
+ test.js

53
tests/node_modules/dotignore/test/index.js generated vendored Normal file
View File

@@ -0,0 +1,53 @@
'use strict';
var fs = require('fs');
var path = require('path');
var rules = String(fs.readFileSync(path.join(process.cwd(), 'test', '.1-ignore')));
var matcher = require('../').createMatcher(rules);
var test = require('tape');
var checkDir = function checkDir(dir, paths, output) {
if (!output) { output = ''; }
paths.forEach(function (pathArr) {
var isDir = Array.isArray(pathArr);
var filename = isDir ? pathArr[0] : pathArr;
var resolved = path.join(dir, filename);
if (matcher.shouldIgnore(resolved)) {
output += '- ' + resolved + '\n';
} else if (isDir) {
output = checkDir(resolved, pathArr[1], output);
} else {
output += '+ ' + resolved + '\n';
}
});
return output;
};
test('expected output', function (t) {
process.chdir(path.join(process.cwd(), 'test'));
var root = [
'.ignore',
[
'a',
[
['a', ['notignored']],
'ignored',
'notignored',
'notlisted'
]
],
'expected',
'test.js'
];
var output = checkDir('.', root);
t.equal(output, String(fs.readFileSync('1-expected')));
t.end();
});
test('delimiter defaults to path.sep', function (t) {
t.equal(matcher.delimiter, path.sep);
t.end();
});