0.4.0 ā€¢ Published 3 years ago

@open-tech-world/node-glob v0.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

@open-tech-world/node-glob

Linux Build Windows Build macOS Build CodeFactor npm

Match files & directories using glob patterns.

It uses @open-tech-worl/es-glob for matching paths.

See the list of supported glob patterns here.

Features

āœ”ļø Sync Matching API

šŸš§ Async Matching API

āœ”ļø Supports Multiple Patterns

Installation

Using npm

npm install @open-tech-world/node-glob

Using Yarn

yarn add @open-tech-world/node-glob

Usage

import { globSync } from '@open-tech-world/node-glob';

globSync(patterns: string | string[], 
         options?: Partial<IOptions>): string[];

Options

NameTypeDefaultDescription
cwdstringprocess.cwd()The current working directory in which to search files & folders.
dotbooleanfalseIf true, it matches files & directories that begin with a "."(dot) character.
absolutebooleanfalseIf true, it returns the absolute path.
dirsbooleantrueIf false, it does not include directories.
filesbooleantrueIf false, it does not include files.

Examples

my-app/
ā”œā”€ node_modules/
ā”œā”€ public/
ā”‚  ā”œā”€ favicon.ico
ā”‚  ā”œā”€ index.html
ā”‚  ā”œā”€ robots.txt
ā”œā”€ src/
ā”‚  ā”œā”€ index.css
ā”‚  ā”œā”€ index.js
ā”œā”€ .gitignore
ā”œā”€ package.json
ā”œā”€ README.md
import { globSync } from '@open-tech-world/node-glob';

globSync(['*']) // ['node_modules', 'public', 'src', 'package.json', 'README.md']

globSync(['*'], { dot: true }) // ['node_modules', 'public', 'src', '.gitignore', 'package.json', 'README.md']

globSync(['*', '!node_modules']) // ['public', 'src', 'package.json', 'README.md']

globSync(['*.json']) // ['package.json']

globSync(['src/index.*']) // ['src/index.css', 'src/index.js']

globSync(['**/index.[a-j]*']) // ['src/index.css', 'src/index.js']

globSync(['public/*.(html|ico)']) // ['public/index.html', 'public/favicon.ico']

License

Copyright (c) 2021, Thanga Ganapathy (MIT License).