Socket
Socket
Sign inDemoInstall

@humanwhocodes/gitignore-to-minimatch

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @humanwhocodes/gitignore-to-minimatch

Utility to convert gitignore patterns to minimatch patterns


Version published
Weekly downloads
782K
decreased by-3.23%
Maintainers
1
Install size
18.4 kB
Created
Weekly downloads
 

Changelog

Source

1.0.2 (2022-03-08)

Bug Fixes

  • Add wildcards to patterns with leading slash (f9df5cf)

Readme

Source

Gitignore to Minimatch Utility

by Nicholas C. Zakas

If you find this useful, please consider supporting my work with a donation.

Description

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.

Usage

Node.js

Install using npm or yarn:

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";

Deno

Import into your Deno project:

import { gitignoreToMinimatch } from "https://cdn.skypack.dev/@humanwhocodes/gitignore-to-minimatch?dts";

Browser

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";

API

After importing, call gitignoreToMinimatch with a string argument, like this:

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

Keywords

FAQs

Last updated on 08 Mar 2022

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc