Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
@zeit/dockerignore
Advanced tools
dockerignore is a manager and filter for .dockerignore rules and is a fork of ignore.
Linux | OS X | Windows | Coverage |
---|---|---|---|
dockerignore
is a manager, filter and parser which is implemented in pure JavaScript according to the .dockerignore spec and is used in production on now-cli
The .dockerignore
spec has a few subtle differences from .gitignore
. If you'd like a great .gitignore
file parser, check out ignore. This package is a fork of ignore
and follows the exact same API.
ignore
?.gitignore
and .dockerignore
specifications
*
in .gitignore
matches everything, whereas in .dockerignore
it only matches things in the current directory (like glob). This difference is important when whitelisting after a *
ruleabc
in .gitignore
matches all abc
files and directories, however deeply nested, however .dockerignore
specifically matches on ./abc
but does not match nested files/directories like ./somedir/abc
.gitignore
, when a parent directory is ignored, subdirectories cannot be re-added (using !
) since git
simply avoids walking through the subtree as an optimization, wheras with .dockerignore
a subdirectory can be re-added even if a parent directory has been ignoredignore
?index.d.ts
file for TypeScript definitions)9.0
(but we use babel
and it should work on older version of Node. Accepting PRs if that isn't the case)yarn add @zeit/dockerignore // or npm install --save @zeit/dockerignore
const ignore = require('@zeit/dockerignore')
const ig = ignore().add(['.abc/*', '!.abc/d/'])
const paths = [
'.abc/a.js', // filtered out
'.abc/d/e.js' // included
]
ig.filter(paths) // ['.abc/d/e.js']
ig.ignores('.abc/a.js') // true
paths.filter(ig.createFilter()); // ['.abc/d/e.js']
ig.filter(['.abc\\a.js', '.abc\\d\\e.js'])
// if the code above runs on windows, the result will be
// ['.abc\\d\\e.js']
docker build
with the test case files and .dockerignore
rules to ensure our tests match what happens with the real docker CLIRead our blog post about the differences between dockerignore
and ignore
and why we built this package.
String|Ignore
An ignore pattern string, or the Ignore
instanceArray.<pattern>
Array of ignore patterns.Adds a rule or several rules to the current manager.
Returns this
Notice that a line starting with '#'
(hash) is treated as a comment. Put a backslash ('\'
) in front of the first hash for patterns that begin with a hash, if you want to ignore a file with a hash at the beginning of the filename.
ignore().add('#abc').ignores('#abc') // false
ignore().add('\#abc').ignores('#abc') // true
pattern
could either be a line of ignore pattern or a string of multiple ignore patterns, which means we could just ignore().add()
the content of a ignore file:
ignore()
.add(fs.readFileSync(filenameOfGitignore).toString())
.filter(filenames)
pattern
could also be an ignore
instance, so that we could easily inherit the rules of another Ignore
instance.
Returns Boolean
whether pathname
should be ignored.
ig.ignores('.abc/a.js') // true
Filters the given array of pathnames, and returns the filtered array.
Array.<path>
The array of pathname
s to be filtered.Creates a filter function which could filter an array of paths with Array.prototype.filter
.
Returns function(path)
the filter function.
Contributions are always welcome and we are fully commited to Open Source.
yarn
or npm install
docker build
)Most of the initial work on this project was done by Kael Zhang (@kaelzhang) and the collaborators on node-ignore
FAQs
dockerignore is a manager and filter for .dockerignore rules and is a fork of ignore.
The npm package @zeit/dockerignore receives a total of 0 weekly downloads. As such, @zeit/dockerignore popularity was classified as not popular.
We found that @zeit/dockerignore demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 50 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.