-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4245348
commit de9de56
Showing
34 changed files
with
617 additions
and
475 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,2 @@ | ||
# Enforce Unix newlines | ||
* text eol=lf | ||
|
||
# binaries | ||
*.ai binary | ||
*.psd binary | ||
*.jpg binary | ||
*.gif binary | ||
*.png binary | ||
*.jpeg binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
github: jonschlinkert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Tests | ||
on: [push, pull_request] | ||
|
||
env: | ||
CI: true | ||
|
||
jobs: | ||
test: | ||
name: Node.js ${{ matrix.node-version }} @ ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
node-version: [10, 12, 13, 14, 15] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm install | ||
- run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,101 +1,62 @@ | ||
## Heads up! | ||
|
||
### Breaking changes in v1.0! | ||
|
||
Prior to v1.0, this library also attempted to convert the returned patterns into valid globs. | ||
|
||
As of v1.0, parse-gitignore was refactored and simplified down to less than ~50 sloc and no dependencies to provide a quick and easy way of getting the array of ignore patterns from a [.gitignore]() file. This allows you to do whatever you need to do with the patterns. | ||
|
||
## Usage | ||
|
||
|
||
```js | ||
const fs = require('fs'); | ||
const gitignore = require('{%= name %}'); | ||
|
||
// pass the contents of a .gitignore file as a string or buffer | ||
console.log(gitignore(fs.readFileSync('foo/bar/.gitignore'))); | ||
//=> ['*.DS_Store', 'node_modules', ...]; | ||
// Pass a string, buffer, or file path to gitignore() | ||
const contents = fs.readFileSync('.gitignore'); | ||
const { patterns, sections } = gitignore(contents); | ||
``` | ||
|
||
## Example | ||
|
||
Parses the contents of a `.gitignore` file, like the folowing: | ||
|
||
```sh | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
``` | ||
|
||
Into an array, like the following: | ||
|
||
```js | ||
[ 'logs', | ||
'*.log', | ||
'npm-debug.log*', | ||
'yarn-debug.log*', | ||
'yarn-error.log*', | ||
'pids', | ||
'*.pid', | ||
'*.seed', | ||
'*.pid.lock' ] | ||
``` | ||
|
||
## .parse | ||
|
||
Given the following contents in `foo/bar/.gitignore`: | ||
|
||
``` | ||
const parsed = gitignore(` | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
``` | ||
|
||
Results in something like the following: | ||
*.seed | ||
`); | ||
|
||
```js | ||
const parsed = gitignore.parse(fs.readFileSync('foo/bar/.gitignore')); | ||
// | ||
// results in the following | ||
// | ||
// | ||
|
||
{ | ||
patterns: [ | ||
'logs', | ||
'*.log', | ||
'npm-debug.log*', | ||
'yarn-debug.log*', | ||
'yarn-error.log*', | ||
'pids', | ||
'*.pid', | ||
'*.seed', | ||
'*.pid.lock' | ||
], | ||
patterns: ['logs', '*.log', 'pids', '*.pid', '*.pid.lock', '*.seed'], | ||
sections: [ | ||
{ | ||
name: 'Logs', | ||
patterns: ['logs', '*.log', 'npm-debug.log*', 'yarn-debug.log*', 'yarn-error.log*'] | ||
value: '# Logs', | ||
patterns: [ 'logs', '*.log'] | ||
}, | ||
{ | ||
name: 'Runtime data', | ||
patterns: ['pids', '*.pid', '*.seed', '*.pid.lock'] | ||
value: '# Runtime data', | ||
patterns: [ 'pids', '*.pid', '*.pid.lock', '*.seed' ] | ||
} | ||
] | ||
} | ||
``` | ||
``` | ||
|
||
## Release history | ||
|
||
### v2.0 | ||
|
||
|
||
|
||
|
||
### v1.0 | ||
|
||
**Heads up! Breaking changes!** | ||
|
||
Prior to v1.0, this library also attempted to convert the returned patterns into valid globs. | ||
|
||
As of v1.0, parse-gitignore was refactored and simplified down to less than ~50 sloc and no dependencies to provide a quick and easy way of getting the array of ignore patterns from a [.gitignore]() file. This allows you to do whatever you need to do with the patterns. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.