dotignore
Advanced tools
Comparing version 0.0.1 to 0.1.0
{ | ||
"name": "dotignore", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "ignorefile/includefile matching .gitignore spec", | ||
@@ -25,4 +25,8 @@ "main": "index.js", | ||
"dependencies": { | ||
"minimatch": "~0.2.9" | ||
"minimatch": "~1.0.0" | ||
}, | ||
"devDependencies": { | ||
"tape": "~2.14.0" | ||
} | ||
} | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var rules = fs.readFileSync(path.join(__dirname, '.ignore'))+''; | ||
var rules = String(fs.readFileSync(path.join(__dirname, '.1-ignore'))); | ||
var matcher = require('../').createMatcher(rules); | ||
var assert = require('assert'); | ||
process.chdir(__dirname); | ||
var output = ''; | ||
function checkDir(dir) { | ||
fs.readdirSync(dir).forEach(function (filename) { | ||
var resolved = path.join(dir, filename); | ||
if (matcher.shouldIgnore(resolved)) { | ||
output += ('- '+resolved+'\n'); | ||
} | ||
else { | ||
if (fs.statSync(resolved).isDirectory()) { | ||
checkDir(resolved); | ||
} | ||
else { | ||
output += ('+ '+resolved+'\n'); | ||
} | ||
} | ||
}) | ||
} | ||
checkDir('.'); | ||
var test = require('tape'); | ||
assert.equal(output, fs.readFileSync(path.join(__dirname, 'expected'))+''); | ||
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(__dirname); | ||
var root = [ | ||
'.ignore', | ||
['a', [ | ||
['a', ['notignored']], | ||
'ignored', | ||
'notignored', | ||
'notlisted' | ||
]], | ||
'expected', | ||
'test.js' | ||
]; | ||
var output = checkDir('.', root); | ||
t.equal(output, String(fs.readFileSync(path.join(__dirname, '1-expected')))); | ||
t.end(); | ||
}); | ||
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
4404
86
27
1
8
1
+ Addedminimatch@1.0.0(transitive)
- Removedminimatch@0.2.14(transitive)
Updatedminimatch@~1.0.0