File tree 2 files changed +7
-4
lines changed
2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -46,27 +46,29 @@ const References = {
46
46
} ;
47
47
48
48
const sourceDir = path . join ( __dirname , "source" ) ;
49
+
49
50
/**
50
51
* get files by glob pattern
51
52
* @param {string } patterns glob pattern
52
53
* "/" root is source directory
53
54
* @see https://github.com/isaacs/node-glob
54
55
*/
55
56
function findByPattern ( patterns ) {
56
- return globby . sync ( patterns , {
57
- root : sourceDir ,
58
- nodir : true ,
57
+ return globby . sync ( path . join ( sourceDir , patterns ) , {
58
+ nodir : true
59
59
} ) ;
60
60
}
61
+
61
62
/**
62
63
* get files by type
63
64
* default all files
64
65
* @param {string } ext
65
66
* e.g) ".md"
66
67
*/
67
68
function get ( ext = ".*" ) {
68
- return findByPattern ( `**/*${ ext } ` ) ;
69
+ return findByPattern ( `/ **/*${ ext } ` ) ;
69
70
}
71
+
70
72
module . exports . References = References ;
71
73
module . exports . findByPattern = findByPattern ;
72
74
module . exports . get = get ;
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ describe("technological-book-corpus-ja", () => {
22
22
describe ( "#findByPattern(ext)" , ( ) => {
23
23
it ( "should get all files that match pattern" , ( ) => {
24
24
const files = corpus . findByPattern ( "/JavaScript-Plugin-Architecture/**/*.md" ) ;
25
+ assert . ok ( files . length > 0 ) ;
25
26
files . every ( filePath => {
26
27
assert ( filePath . includes ( "JavaScript-Plugin-Architecture/" ) ) ;
27
28
} ) ;
You can’t perform that action at this time.
0 commit comments