1 | const fs = require('fs')
|
2 | const path = require('path')
|
3 |
|
4 | const cache = {}
|
5 |
|
6 | module.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 | }
|