New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dat-ignore

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dat-ignore - npm Package Compare versions

Comparing version 1.1.2 to 2.0.0

test/.datignore2

14

index.js

@@ -0,1 +1,2 @@

var assert = require('assert')
var fs = require('fs')

@@ -9,11 +10,8 @@ var path = require('path')

function ignore (dir, opts) {
if (typeof dir !== 'string') {
opts = dir
dir = null
}
assert.equal(typeof dir, 'string', 'dat-ignore: directory required')
opts = xtend({
datignorePath: dir ? path.join(dir, '.datignore') : '.datignore'
datignorePath: path.join(dir, '.datignore')
}, opts)
var allow = ['!**/.well-known/dat']
var allow = ['!**/.well-known/dat', '!.well-known/dat']
var ignoreMatches = opts.ignore // we end up with array of ignores here

@@ -36,3 +34,3 @@ ? Array.isArray(opts.ignore)

return function (file) {
if (dir) file = file.replace(dir, '') // remove dir so we do not ignore that
file = file.replace(dir, '') // remove dir so we do not ignore anything in that path
file = file.replace(/^\//, '')

@@ -48,3 +46,3 @@ return match(ignoreMatches, file)

.trim()
.split('\r?\n')
.split(/[\r\n]+/g)
.filter(function (str) {

@@ -51,0 +49,0 @@ return !!str.trim()

{
"name": "dat-ignore",
"description": "default ignore for dat",
"version": "1.1.2",
"version": "2.0.0",
"author": "Joe Hand <joe@hand.email>",

@@ -6,0 +6,0 @@ "bugs": {

@@ -80,3 +80,3 @@ # dat-ignore

### `var ignore = datIgnore([dir], [opts])`
### `var ignore = datIgnore(dir, [opts])`

@@ -93,3 +93,3 @@ Returns a function that checks if a path should be ignored:

`dir` is used to find `.datignore` and is prepended to paths found in `.datignore`.
`dir` is the file root to compare to. It is also used to find `.datignore`, if not specified.

@@ -96,0 +96,0 @@ #### Options:

@@ -80,15 +80,33 @@ var fs = require('fs')

test('without dir ok', function (t) {
var ignore = datIgnore()
checkDefaults(t, ignore)
test('well-known not ignored', function (t) {
var ignore = datIgnore(__dirname)
t.notOk(ignore(path.join(__dirname, '.well-known/dat')), 'well known dat not ignored')
t.end()
})
test('well-known not ignored', function (t) {
var ignore = datIgnore()
checkDefaults(t, ignore)
t.notOk(ignore(path.join(__dirname, '.well-known/dat')), 'well known dat not ignored')
test('node_modules ignored', function (t) {
var ignore = datIgnore(__dirname)
t.ok(ignore(path.join(__dirname, 'node_modules')), 'node_modules ignored')
t.end()
})
test('node_modules subdir ignored', function (t) {
var ignore = datIgnore(__dirname)
t.ok(ignore(path.join(__dirname, 'node_modules', 'dat')), 'node_modules subdir ignored')
t.end()
})
test('node_modules file ignored', function (t) {
var ignore = datIgnore(__dirname)
t.ok(ignore(path.join(__dirname, 'node_modules', 'dat', 'hello.txt')), 'node_modules subdir ignored')
t.end()
})
test('throws without directory option', function (t) {
t.throws(function () {
datIgnore({opts: true})
})
t.end()
})
function checkDefaults (t, ignore) {

@@ -95,0 +113,0 @@ // Default Ignore

Sorry, the diff of this file is not supported yet

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