Skip to content

Commit

Permalink
fix: node_modules can have folders with .js extension (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Nov 21, 2019
1 parent 23e08a7 commit dccba19
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Empty file added fixtures/bignumber.js/.gitkeep
Empty file.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

const glob = require('glob')
const { readFileSync } = require('fs')
const { readFileSync, statSync } = require('fs')
const { resolve } = require('path')

const SAMPLES_DIRECTORY = process.env.SAMPLES_DIRECTORY || resolve(process.cwd(), './samples')
Expand All @@ -26,6 +26,8 @@ const sampleCache = new Map()
exports.loadSampleCache = function () {
const sampleCandidates = glob.sync(`${SAMPLES_DIRECTORY}/**/*.{js,ts}`, { ignore: ['node_modules'] })
for (const candidate of sampleCandidates) {
const stat = statSync(candidate)
if (!stat.isFile()) continue
const content = readFileSync(candidate, 'utf8')
if (REGION_START_REGEX.test(content)) {
parseSamples(content)
Expand Down

0 comments on commit dccba19

Please sign in to comment.