Skip to content

Commit

Permalink
Reduce dependencies by replacing cosmiconfig to lilconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Dec 2, 2020
1 parent 365aec7 commit 29e47a2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
13 changes: 7 additions & 6 deletions packages/size-limit/get-config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
let { isAbsolute, dirname, join, relative } = require('path')
let { cosmiconfig } = require('cosmiconfig')
let { lilconfig } = require('lilconfig')
let globby = require('globby')
let bytes = require('bytes')

Expand Down Expand Up @@ -99,7 +99,7 @@ module.exports = async function getConfig (plugins, process, args, pkg) {
if (args.files.length > 0) {
config.checks = [{ files: args.files }]
} else {
let explorer = cosmiconfig('size-limit', {
let explorer = lilconfig('size-limit', {
searchPlaces: [
'package.json',
'.size-limit.json',
Expand All @@ -116,18 +116,19 @@ module.exports = async function getConfig (plugins, process, args, pkg) {
config.cwd = dirname(result.filepath)
config.checks = await Promise.all(
result.config.map(async check => {
let processed = { ...check }
if (check.path) {
check.files = await globby(check.path, { cwd: config.cwd })
processed.files = await globby(check.path, { cwd: config.cwd })
} else if (!check.entry) {
if (pkg.packageJson.main) {
check.files = [
processed.files = [
require.resolve(join(dirname(pkg.path), pkg.packageJson.main))
]
} else {
check.files = [join(dirname(pkg.path), 'index.js')]
processed.files = [join(dirname(pkg.path), 'index.js')]
}
}
return check
return processed
})
)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/size-limit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"chokidar": "^3.4.3",
"ci-job-number": "^1.2.2",
"colorette": "^1.2.1",
"cosmiconfig": "^7.0.0",
"globby": "^11.0.1",
"lilconfig": "^2.0.1",
"ora": "^5.1.0",
"read-pkg-up": "^7.0.1"
}
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5055,6 +5055,11 @@ levn@~0.3.0:
prelude-ls "~1.1.2"
type-check "~0.3.2"

lilconfig@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.0.1.tgz#24353e5eadfbd7fcf314bad46714161e4e085ebf"
integrity sha512-fFzm+Lj/Up8OGJfygxz1VLVuihcqZQpqFMmQ3yklVwUIA8Z6LWBwiISObInLg8R8g9E9r7b9t2+kh8+N7vRS+g==

line-column@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/line-column/-/line-column-1.0.2.tgz#d25af2936b6f4849172b312e4792d1d987bc34a2"
Expand Down

0 comments on commit 29e47a2

Please sign in to comment.