File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -46,27 +46,29 @@ const References = {
4646} ;
4747
4848const sourceDir = path . join ( __dirname , "source" ) ;
49+
4950/**
5051 * get files by glob pattern
5152 * @param {string } patterns glob pattern
5253 * "/" root is source directory
5354 * @see https://github.com/isaacs/node-glob
5455 */
5556function findByPattern ( patterns ) {
56- return globby . sync ( patterns , {
57- root : sourceDir ,
58- nodir : true ,
57+ return globby . sync ( path . join ( sourceDir , patterns ) , {
58+ nodir : true
5959 } ) ;
6060}
61+
6162/**
6263 * get files by type
6364 * default all files
6465 * @param {string } ext
6566 * e.g) ".md"
6667 */
6768function get ( ext = ".*" ) {
68- return findByPattern ( `**/*${ ext } ` ) ;
69+ return findByPattern ( `/ **/*${ ext } ` ) ;
6970}
71+
7072module . exports . References = References ;
7173module . exports . findByPattern = findByPattern ;
7274module . exports . get = get ;
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ describe("technological-book-corpus-ja", () => {
2222 describe ( "#findByPattern(ext)" , ( ) => {
2323 it ( "should get all files that match pattern" , ( ) => {
2424 const files = corpus . findByPattern ( "/JavaScript-Plugin-Architecture/**/*.md" ) ;
25+ assert . ok ( files . length > 0 ) ;
2526 files . every ( filePath => {
2627 assert ( filePath . includes ( "JavaScript-Plugin-Architecture/" ) ) ;
2728 } ) ;
You can’t perform that action at this time.
0 commit comments