File tree Expand file tree Collapse file tree 5 files changed +41
-28
lines changed
verify-version-change/dist Expand file tree Collapse file tree 5 files changed +41
-28
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,11 @@ describe('path utils', () => {
99 patterns : [ ] ,
1010 expected : [ ]
1111 } ,
12+ {
13+ paths : [ 'a.ts' , 'a.js' , 'b.md' ] ,
14+ patterns : [ ] ,
15+ expected : [ 'a.ts' , 'a.js' , 'b.md' ]
16+ } ,
1217 {
1318 paths : [ 'a.ts' , 'a.js' , 'b.md' ] ,
1419 patterns : [ 'b*.*' ] ,
Original file line number Diff line number Diff line change @@ -24,11 +24,13 @@ function filterPathsImpl(
2424 paths : string [ ] ,
2525 patterns : string [ ] ,
2626) : string [ ] {
27- return paths . filter ( path => {
28- return patterns . reduce ( ( prevResult , pattern ) => {
29- return pattern . startsWith ( NEGATION )
30- ? prevResult && ! match ( path , pattern . substring ( 1 ) )
31- : prevResult || match ( path , pattern ) ;
32- } , false ) ;
33- } ) ;
27+ return patterns ?. length === 0
28+ ? paths
29+ : paths . filter ( path => {
30+ return patterns . reduce ( ( prevResult , pattern ) => {
31+ return pattern . startsWith ( NEGATION )
32+ ? prevResult && ! match ( path , pattern . substring ( 1 ) )
33+ : prevResult || match ( path , pattern ) ;
34+ } , false ) ;
35+ } ) ;
3436}
Original file line number Diff line number Diff line change @@ -144,13 +144,15 @@ function filterPaths(paths, patterns) {
144144}
145145exports.filterPaths = filterPaths;
146146function filterPathsImpl(paths, patterns) {
147- return paths.filter(path => {
148- return patterns.reduce((prevResult, pattern) => {
149- return pattern.startsWith(NEGATION)
150- ? prevResult && !match(path, pattern.substring(1))
151- : prevResult || match(path, pattern);
152- }, false);
153- });
147+ return (patterns === null || patterns === void 0 ? void 0 : patterns.length) === 0
148+ ? paths
149+ : paths.filter(path => {
150+ return patterns.reduce((prevResult, pattern) => {
151+ return pattern.startsWith(NEGATION)
152+ ? prevResult && !match(path, pattern.substring(1))
153+ : prevResult || match(path, pattern);
154+ }, false);
155+ });
154156}
155157
156158
Original file line number Diff line number Diff line change @@ -144,13 +144,15 @@ function filterPaths(paths, patterns) {
144144}
145145exports.filterPaths = filterPaths;
146146function filterPathsImpl(paths, patterns) {
147- return paths.filter(path => {
148- return patterns.reduce((prevResult, pattern) => {
149- return pattern.startsWith(NEGATION)
150- ? prevResult && !match(path, pattern.substring(1))
151- : prevResult || match(path, pattern);
152- }, false);
153- });
147+ return (patterns === null || patterns === void 0 ? void 0 : patterns.length) === 0
148+ ? paths
149+ : paths.filter(path => {
150+ return patterns.reduce((prevResult, pattern) => {
151+ return pattern.startsWith(NEGATION)
152+ ? prevResult && !match(path, pattern.substring(1))
153+ : prevResult || match(path, pattern);
154+ }, false);
155+ });
154156}
155157
156158
Original file line number Diff line number Diff line change @@ -144,13 +144,15 @@ function filterPaths(paths, patterns) {
144144}
145145exports.filterPaths = filterPaths;
146146function filterPathsImpl(paths, patterns) {
147- return paths.filter(path => {
148- return patterns.reduce((prevResult, pattern) => {
149- return pattern.startsWith(NEGATION)
150- ? prevResult && !match(path, pattern.substring(1))
151- : prevResult || match(path, pattern);
152- }, false);
153- });
147+ return (patterns === null || patterns === void 0 ? void 0 : patterns.length) === 0
148+ ? paths
149+ : paths.filter(path => {
150+ return patterns.reduce((prevResult, pattern) => {
151+ return pattern.startsWith(NEGATION)
152+ ? prevResult && !match(path, pattern.substring(1))
153+ : prevResult || match(path, pattern);
154+ }, false);
155+ });
154156}
155157
156158
You can’t perform that action at this time.
0 commit comments