untracked 1.4.7 → 1.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/load-config.js +17 -12
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "untracked",
3
3
  "description": "Universal way for ignoring unnecessary common files to fit your bundle",
4
4
  "homepage": "https://nicedoc.io/Kikobeats/untracked",
5
- "version": "1.4.7",
5
+ "version": "1.4.8",
6
6
  "main": "src/index.js",
7
7
  "bin": {
8
8
  "untracked": "bin/index.js"
@@ -3,21 +3,26 @@
3
3
  const { get } = require('lodash')
4
4
  const JoyCon = require('joycon')
5
5
 
6
- const joycon = new JoyCon({
7
- packageKey: 'untracked',
8
- files: [
9
- 'package.json',
10
- '.untrackedrc',
11
- '.untrackedrc.json',
12
- '.untrackedrc.js',
13
- 'untracked.config.js'
14
- ]
15
- })
16
-
17
6
  const DEFAULT = {
18
7
  blacklist: require('./default/blacklist')
19
8
  }
20
9
 
10
+ const loadConfig = async cwd => {
11
+ const joycon = new JoyCon({
12
+ cwd,
13
+ packageKey: 'untracked',
14
+ files: [
15
+ 'package.json',
16
+ '.untrackedrc',
17
+ '.untrackedrc.json',
18
+ '.untrackedrc.js',
19
+ 'untracked.config.js'
20
+ ]
21
+ })
22
+ const { data: configFile } = await joycon.load()
23
+ return configFile
24
+ }
25
+
21
26
  const createCollection = (configFile, propName) => {
22
27
  const collection = new Set(get(configFile, `config.${propName}`, []))
23
28
  DEFAULT[propName] && DEFAULT[propName].forEach(item => collection.add(item))
@@ -25,7 +30,7 @@ const createCollection = (configFile, propName) => {
25
30
  }
26
31
 
27
32
  module.exports = async ({ cwd = process.cwd() }) => {
28
- const { data: configFile } = await joycon.load()
33
+ const configFile = await loadConfig(cwd)
29
34
 
30
35
  return {
31
36
  whitelist: createCollection(configFile, 'whitelist'),