Socket
Socket
Sign inDemoInstall

glob-parent

Package Overview
Dependencies
2
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    glob-parent

Strips glob magic from a string to provide the parent path


Version published
Weekly downloads
89M
decreased by-0.72%
Maintainers
1
Install size
16.5 kB
Created
Weekly downloads
 

Package description

What is glob-parent?

The glob-parent npm package is used to extract the non-magic parent path from a glob string, which is useful for determining the directory that a glob is intended to match against, for ensuring consistent behavior in file watching and globbing.

What are glob-parent's main functionalities?

Extracting non-magic parent path from a glob string

This feature allows you to get the directory path without any glob patterns, which is useful for file operations that require a base directory.

const globParent = require('glob-parent');

console.log(globParent('path/to/*.js')); // Output: 'path/to'

Other packages similar to glob-parent

Changelog

Source

2.0.0 (2021-01-27)

Features

  • move up to dirname regardless of glob characters (f97fb83)

Readme

Source

glob-parent Build Status Coverage Status

Javascript module to extract the non-magic parent path from a glob string.

NPM NPM

Usage

npm install glob-parent --save
var globParent = require('glob-parent');

globParent('path/to/*.js'); // 'path/to'
globParent('/root/path/to/*.js'); // '/root/path/to'
globParent('/*.js'); // '/'
globParent('*.js'); // '.'
globParent('**/*.js'); // '.'
globParent('path/{to,from}'); // 'path'
globParent('path/!(to|from)'); // 'path'
globParent('path/?(to|from)'); // 'path'
globParent('path/+(to|from)'); // 'path'
globParent('path/*(to|from)'); // 'path'
globParent('path/@(to|from)'); // 'path'
globParent('path/**/*'); // 'path'

// if provided a non-glob path, returns the nearest dir
globParent('path/foo/bar.js'); // 'path/foo'
globParent('path/foo/'); // 'path/foo'
globParent('path/foo'); // 'path' (see issue #3 for details)

Change Log

See release notes page on GitHub

License

ISC

Keywords

FAQs

Last updated on 18 Sep 2015

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