Socket
Socket
Sign inDemoInstall

dotignore

Package Overview
Dependencies
3
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.1 to 0.1.0

.npmignore

8

package.json
{
"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();
});
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc