bajo 0.2.1 → 0.2.3

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.
@@ -1,11 +1,12 @@
1
1
  import path from 'path'
2
2
  import fs from 'fs-extra'
3
+ import { get } from 'lodash-es'
3
4
  import getGlobalModuleDir from './get-global-module-dir.js'
4
5
  import resolvePath from './resolve-path.js'
5
6
  import { createRequire } from 'module'
6
7
  const require = createRequire(import.meta.url)
7
8
 
8
- const findDeep = (item, paths) => {
9
+ function findDeep (item, paths) {
9
10
  let dir
10
11
  for (const p of paths) {
11
12
  const d = `${p}/${item}`
@@ -17,9 +18,10 @@ const findDeep = (item, paths) => {
17
18
  return dir
18
19
  }
19
20
 
20
- const getModuleDir = (pkgName, base) => {
21
+ function getModuleDir (pkgName, base) {
21
22
  if (pkgName === 'app') return resolvePath(process.env.BAJOCWD)
22
23
  if (base === 'app') base = process.env.BAJOCWD
24
+ else if (this && this[base]) base = get(this[base], 'config.pkg.name')
23
25
  const pkgPath = pkgName + '/package.json'
24
26
  const paths = require.resolve.paths(pkgPath)
25
27
  const gdir = getGlobalModuleDir()
package/boot/index.js CHANGED
@@ -19,7 +19,6 @@ import exitHandler from './exit-handler.js'
19
19
  import runTool from './run-tool.js'
20
20
  import shim from './lib/shim.js'
21
21
  import { last } from 'lodash-es'
22
- import path from 'path'
23
22
  import resolvePath from './helper/resolve-path.js'
24
23
 
25
24
  shim()
@@ -33,7 +32,7 @@ shim()
33
32
  */
34
33
 
35
34
  async function boot (cwd) {
36
- if (!cwd) cwd = path.dirname(process.argv[1])
35
+ if (!cwd) cwd = process.cwd()
37
36
  const l = last(process.argv)
38
37
  if (l.startsWith('--cwd')) {
39
38
  const parts = l.split('=')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "A framework to build a giant monstrous app rapidly",
5
5
  "main": "boot/index.js",
6
6
  "scripts": {
@@ -1,50 +0,0 @@
1
- import getGlobalModuleDir from './get-global-module-dir.js'
2
- import resolvePath from './resolve-path.js'
3
- import { createRequire } from 'module'
4
- const require = createRequire(import.meta.url)
5
-
6
- function getDir (name, ns) {
7
- const checker = '/package.json'
8
- name = name + checker
9
- let dir
10
- let c = 0
11
- try {
12
- dir = require.resolve(resolvePath(name))
13
- c = 1
14
- } catch (err) {
15
- try {
16
- dir = require.resolve(name)
17
- c = 2
18
- } catch (err) {
19
- try {
20
- dir = require.resolve(process.cwd() + '/node_modules/' + name)
21
- c = 3
22
- } catch (err) {
23
- try {
24
- dir = getGlobalModuleDir(name, false)
25
- c = 4
26
- } catch (err) {
27
- if (ns) {
28
- const d = getGlobalModuleDir(null)
29
- dir = require.resolve(`${d}/${ns}/node_modules/${name}`)
30
- c = 5
31
- }
32
- }
33
- }
34
- }
35
- }
36
- if (!dir) return
37
- return dir.slice(0, dir.length - checker.length)
38
- }
39
-
40
- const getModuleDir = (pkgName, ns) => {
41
- let dir
42
- if (pkgName === 'app') {
43
- dir = process.env.BAJOCWD
44
- } else {
45
- dir = getDir(pkgName, ns)
46
- }
47
- return dir
48
- }
49
-
50
- export default getModuleDir