0.0.2 • Published 1 year ago

gitignore-to-minimatch v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

gitignore-to-minimatch

npm version install size jsdocs license

Convert gitignore patterns to minimatch patterns.

Installation

npm install gitignore-to-minimatch

Usage

import { gitignoreToMinimatch } from 'gitignore-to-minimatch'

// provide a single gitignore pattern string, return an array of minimatch patterns
const minimatchPatterns = gitignoreToMinimatch('dist')
// => [ '/**/dist', '/**/dist/**' ]

Why Array?

However, if you set the pattern dist in .gitignore, it may match the file dist and the directory dist/ at the same time. A single minimatch pattern can't represent this situation.

For the result ['/**/dist', '/**/dist/**'], /**/dist matches the file or directory dist without its contents, and /**/dist/** matches the whole directory dist/ with all its contents.

Motivation

In my another repository ncreate, I need to duplicate an existing local repository to a new one but ignore some files based on the .gitignore file. I found that there is a few differences between .gitignore and minimatch patterns. So...

Reference

gitignore documentation

0.0.2

1 year ago

0.0.1

1 year ago

0.0.0

1 year ago

8.0.11

3 years ago