Gathering detailed insights and metrics for @snyk/glob-parent
Gathering detailed insights and metrics for @snyk/glob-parent
Gathering detailed insights and metrics for @snyk/glob-parent
Gathering detailed insights and metrics for @snyk/glob-parent
npm install @snyk/glob-parent
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
79 Stars
89 Commits
46 Forks
15 Watching
2 Branches
11 Contributors
Updated on 29 Aug 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-4.4%
1,076
Compared to previous day
Last week
-37.8%
6,048
Compared to previous week
Last month
103%
26,887
Compared to previous month
Last year
-36.3%
409,029
Compared to previous year
Extract the non-magic parent path from a glob string.
1var globParent = require('glob-parent'); 2 3globParent('path/to/*.js'); // 'path/to' 4globParent('/root/path/to/*.js'); // '/root/path/to' 5globParent('/*.js'); // '/' 6globParent('*.js'); // '.' 7globParent('**/*.js'); // '.' 8globParent('path/{to,from}'); // 'path' 9globParent('path/!(to|from)'); // 'path' 10globParent('path/?(to|from)'); // 'path' 11globParent('path/+(to|from)'); // 'path' 12globParent('path/*(to|from)'); // 'path' 13globParent('path/@(to|from)'); // 'path' 14globParent('path/**/*'); // 'path' 15 16// if provided a non-glob path, returns the nearest dir 17globParent('path/foo/bar.js'); // 'path/foo' 18globParent('path/foo/'); // 'path/foo' 19globParent('path/foo'); // 'path' (see issue #3 for details)
globParent(maybeGlobString, [options])
Takes a string and returns the part of the path before the glob begins. Be aware of Escaping rules and Limitations below.
1{ 2 // Disables the automatic conversion of slashes for Windows 3 flipBackslashes: true; 4}
The following characters have special significance in glob patterns and must be escaped if you want them to be treated as regular path characters:
?
(question mark) unless used as a path segment alone*
(asterisk)|
(pipe)(
(opening parenthesis))
(closing parenthesis){
(opening curly brace)}
(closing curly brace)[
(opening bracket)]
(closing bracket)Example
1globParent('foo/[bar]/'); // 'foo' 2globParent('foo/\\[bar]/'); // 'foo/[bar]'
This library attempts a quick and imperfect method of determining which path parts have glob magic without fully parsing/lexing the pattern. There are some advanced use cases that can trip it up, such as nested braces where the outer pair is escaped and the inner one contains a path separator. If you find yourself in the unlikely circumstance of being affected by this or need to ensure higher-fidelity glob handling in your library, it is recommended that you pre-process your input with expand-braces and/or expand-brackets.
Backslashes are not valid path separators for globs. If a path with backslashes is provided anyway, for simple cases, glob-parent will replace the path separator for you and return the non-glob parent path (now with forward-slashes, which are still valid as Windows path separators).
This cannot be used in conjunction with escape characters.
1// BAD 2globParent('C:\\Program Files \\(x86\\)\\*.ext'); // 'C:/Program Files /(x86/)' 3 4// GOOD 5globParent('C:/Program Files\\(x86\\)/*.ext'); // 'C:/Program Files (x86)'
If you are using escape characters for a pattern without path parts (i.e.
relative to cwd
), prefix with ./
to avoid confusing glob-parent.
1// BAD 2globParent('foo \\[bar]'); // 'foo ' 3globParent('foo \\[bar]*'); // 'foo ' 4 5// GOOD 6globParent('./foo \\[bar]'); // 'foo [bar]' 7globParent('./foo \\[bar]*'); // '.'
ISC
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
Found 6/27 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More