MCPcopy
hub / github.com/ampproject/amphtml / gitignoreToGlobPattern

Function gitignoreToGlobPattern

build-system/tasks/clean.js:19–28  ·  view source on GitHub ↗

* Rewrite glob patterns according to .gitignore syntax relative to cwd. * https://git-scm.com/docs/gitignore#_pattern_format * @param {string} pattern In .gitignore format * @return {string} Pattern in standard glob format

(pattern)

Source from the content-addressed store, hash-verified

17 * @return {string} Pattern in standard glob format
18 */
19function gitignoreToGlobPattern(pattern) {
20 // If there is a separator at the beginning or middle (or both) of the
21 // pattern, then the pattern is relative to the directory level of the
22 // particular .gitignore file itself.
23 if (pattern.startsWith('/')) {
24 return pattern.substr(1);
25 }
26 // Otherwise the pattern may also match at any level below the .gitignore level.
27 return `**/${pattern}`;
28}
29
30/**
31 * @return {Promise<string[]>}

Callers 1

getPathsFromIgnoreListFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected