bajo 0.2.3 → 0.2.4

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.
@@ -16,7 +16,7 @@ import parseEnv from './lib/parse-env.js'
16
16
  import error from './helper/error.js'
17
17
  import currentLoc from './helper/current-loc.js'
18
18
 
19
- const configFilePick = ['log', 'plugins', 'env', 'run']
19
+ const configFilePick = ['log', 'plugins', 'env', 'run', 'exitHandler']
20
20
  const configFileOmit = ['tool', 'spawn', 'cwd', 'name', 'alias']
21
21
 
22
22
  const defConfig = {
@@ -29,7 +29,7 @@ import fs from 'fs-extra'
29
29
 
30
30
  const importPkg = async (...pkg) => {
31
31
  const result = {}
32
- let opts = { returnDefault: true }
32
+ let opts = { returnDefault: true, thrownNotFound: false }
33
33
  if (isPlainObject(last(pkg))) {
34
34
  opts = defaultsDeep(pkg.pop(), opts)
35
35
  }
@@ -45,7 +45,7 @@ const importPkg = async (...pkg) => {
45
45
  }
46
46
  if (isEmpty(name)) name = orgName
47
47
  const dir = getModuleDir(orgName, ns)
48
- const pkg = readJson(`${dir}/package.json`)
48
+ const pkg = readJson(`${dir}/package.json`, opts.thrownNotFound)
49
49
  const mainFileOrg = dir + '/' + (pkg.main ?? get(pkg, 'exports.default', 'index.js'))
50
50
  let mainFile = resolvePath(mainFileOrg, os.platform() === 'win32')
51
51
  if (isEmpty(path.extname(mainFile))) {
@@ -1,7 +1,8 @@
1
1
  import fs from 'fs-extra'
2
2
  import { isEmpty } from 'lodash-es'
3
3
 
4
- const readJson = (file) => {
4
+ const readJson = (file, thrownNotFound) => {
5
+ if (!fs.existsSync(file) && thrownNotFound) throw new Error('File \'%s\' not found', file)
5
6
  let resp = fs.readFileSync(file, 'utf8')
6
7
  if (isEmpty(resp)) resp = '{}'
7
8
  return JSON.parse(resp)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "A framework to build a giant monstrous app rapidly",
5
5
  "main": "boot/index.js",
6
6
  "scripts": {