Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!hasValidExtension(path, context)) {
exportCache.set(cacheKey, null)
return null
}
// check for and cache ignore
if (isIgnored(path, context)) {
log('ignored path due to ignore settings:', path)
exportCache.set(cacheKey, null)
return null
}
const content = fs.readFileSync(path, { encoding: 'utf8' })
// check for and cache unambigious modules
if (!unambiguous.test(content)) {
log('ignored path due to unambiguous regex:', path)
exportCache.set(cacheKey, null)
return null
}
log('cache miss', cacheKey, 'for path', path)
exportMap = ExportMap.parse(path, content, context)
// ambiguous modules return null
if (exportMap == null) return null
exportMap.mtime = stats.mtime
exportCache.set(cacheKey, exportMap)
return exportMap
}
it(`works for ${testFile} (${expectedRegexResult})`, function () {
const content = fs.readFileSync('./tests/files/' + testFile, 'utf8')
expect(unambiguous.test(content)).to.equal(expectedRegexResult)
})
}