If you find this useful, please consider supporting my work with a donation.
A function that converts a gitignore pattern into a 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.
npm install @humanwhocodes/gitignore-to-minimatch --save
# or
yarn add @humanwhocodes/gitignore-to-minimatch
Import into your Node.js project:
// CommonJS
const { gitignoreToMinimatch } = require("@humanwhocodes/gitignore-to-minimatch");
// ESM
import { gitignoreToMinimatch } from "@humanwhocodes/gitignore-to-minimatch";
Import into your Deno project:
import { gitignoreToMinimatch } from "https://cdn.skypack.dev/@humanwhocodes/gitignore-to-minimatch?dts";
It's recommended to import the minified version to save bandwidth:
import { gitignoreToMinimatch } from "https://cdn.skypack.dev/@humanwhocodes/gitignore-to-minimatch?min";
However, you can also import the unminified version for debugging purposes:
import { gitignoreToMinimatch } from "https://cdn.skypack.dev/@humanwhocodes/gitignore-to-minimatch";
After importing, call gitignoreToMinimatch
with a string argument, like this:
const minimatchPattern = gitignoreToMinimatch("foo");
console.log(minimatchPattern); // "**/foo"
- Fork the repository
- Clone your fork
- Run
npm install
to setup dependencies - Run
npm test
to run tests
Apache 2.0