MCPcopy Create free account
hub / github.com/browserslist/browserslist / parsePackage

Function parsePackage

node.js:152–176  ·  view source on GitHub ↗
(file)

Source from the content-addressed store, hash-verified

150}
151
152function parsePackage(file) {
153 var text = fs
154 .readFileSync(file)
155 .toString()
156 .replace(/^\uFEFF/m, '')
157 var list
158 if (text.indexOf('"browserslist"') >= 0) {
159 list = JSON.parse(text).browserslist
160 } else if (text.indexOf('"browserlist"') >= 0) {
161 var config = JSON.parse(text)
162 if (config.browserlist && !config.browserslist) {
163 throw new BrowserslistError(
164 '`browserlist` key instead of `browserslist` in ' + file
165 )
166 }
167 }
168 if (Array.isArray(list) || typeof list === 'string') {
169 list = { defaults: list }
170 }
171 for (var i in list) {
172 check(list[i])
173 }
174
175 return list
176}
177
178function parsePackageOrReadConfig(file) {
179 if (file in parseConfigCache) {

Callers 2

parsePackageOrReadConfigFunction · 0.85
node.jsFile · 0.85

Calls 1

checkFunction · 0.85

Tested by

no test coverage detected