Skip to content

Commit c203ce8

Browse files
committed
fix: use path.join instead of root options
1 parent b4864c0 commit c203ce8

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,29 @@ const References = {
4646
};
4747

4848
const 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
*/
5556
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
5959
});
6060
}
61+
6162
/**
6263
* get files by type
6364
* default all files
6465
* @param {string} ext
6566
* e.g) ".md"
6667
*/
6768
function get(ext = ".*") {
68-
return findByPattern(`**/*${ext}`);
69+
return findByPattern(`/**/*${ext}`);
6970
}
71+
7072
module.exports.References = References;
7173
module.exports.findByPattern = findByPattern;
7274
module.exports.get = get;

test/index-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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
});

0 commit comments

Comments
 (0)