Urara-Blog/node_modules/.pnpm-store/v3/files/43/3e1d685da327343099a91fd72a3ca24f22d5cd0a32d12653fb02e9d43a71aff147fa1924ba45e56532eb89c8fbd03f045cdb2c85566ada237a099282f32f97
2022-08-14 01:14:53 +08:00

78 lines
1.8 KiB
Text

# Gitignore to Minimatch Utility
by [Nicholas C. Zakas](https://humanwhocodes.com)
If you find this useful, please consider supporting my work with a [donation](https://humanwhocodes.com/donate).
## Description
A function that converts a [gitignore](https://git-scm.com/docs/gitignore#_pattern_format) pattern into a [minimatch](https://github.com/isaacs/minimatch) pattern. There are subtle differences between these two formats, and depending on the utilities you're using, you may need one or the other.
## Usage
### Node.js
Install using [npm][npm] or [yarn][yarn]:
```
npm install @humanwhocodes/gitignore-to-minimatch --save
# or
yarn add @humanwhocodes/gitignore-to-minimatch
```
Import into your Node.js project:
```js
// CommonJS
const { gitignoreToMinimatch } = require("@humanwhocodes/gitignore-to-minimatch");
// ESM
import { gitignoreToMinimatch } from "@humanwhocodes/gitignore-to-minimatch";
```
### Deno
Import into your Deno project:
```js
import { gitignoreToMinimatch } from "https://cdn.skypack.dev/@humanwhocodes/gitignore-to-minimatch?dts";
```
### Browser
It's recommended to import the minified version to save bandwidth:
```js
import { gitignoreToMinimatch } from "https://cdn.skypack.dev/@humanwhocodes/gitignore-to-minimatch?min";
```
However, you can also import the unminified version for debugging purposes:
```js
import { gitignoreToMinimatch } from "https://cdn.skypack.dev/@humanwhocodes/gitignore-to-minimatch";
```
## API
After importing, call `gitignoreToMinimatch` with a string argument, like this:
```js
const minimatchPattern = gitignoreToMinimatch("foo");
console.log(minimatchPattern); // "**/foo"
```
## Developer Setup
1. Fork the repository
2. Clone your fork
3. Run `npm install` to setup dependencies
4. Run `npm test` to run tests
## License
Apache 2.0
[npm]: https://npmjs.com/
[yarn]: https://yarnpkg.com/