UNPKG

366 BJavaScriptView Raw
1const fs = require('fs')
2const path = require('path')
3
4const cache = {}
5
6module.exports = function(packageName) {
7 if (packageName in cache) {
8 return cache[packageName]
9 }
10
11 try {
12 fs.statSync(path.resolve('node_modules', packageName))
13 cache[packageName] = true
14 return true
15 } catch (error) {
16 cache[packageName] = false
17 return false
18 }
19}