node-karin 0.6.25 → 0.6.26

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.
@@ -256,7 +256,7 @@ class PluginLoader {
256
256
  async createdApp (dir, name, isOrderBy = false, isNpm = false) {
257
257
  try {
258
258
  const list = []
259
- let path = `${this.dirPath}${isNpm ? 'node_modules ' : 'plugins'}/${dir}/${name}`
259
+ let path = `${this.dirPath}${isNpm ? 'node_modules' : 'plugins'}/${dir}/${name}`
260
260
  if (isOrderBy) { path = path + `?${Date.now()}` }
261
261
  const tmp = await import(path)
262
262
  lodash.forEach(tmp, (App) => {
@@ -413,14 +413,21 @@ export const common = new (class Common {
413
413
  try {
414
414
  const pkgPath = path.join(process.cwd(), 'node_modules', name, 'package.json')
415
415
  const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
416
- if (pkg?.karin && pkg?.karin?.apps?.length) {
417
- pkg.karin.apps.forEach((app) => {
418
- fs.readdirSync(`./node_modules/${name}/${app}`).forEach((dir) => {
419
- /** 忽略非js */
420
- if (!dir.endsWith('.js')) { return }
421
- list.push({ dir, name })
416
+ if (pkg?.karin) {
417
+ if (pkg?.main) {
418
+ const dir = `${name}/${path.dirname(pkg.main).replace(/\.\//, '')}`
419
+ list.push({ dir, name: path.basename(pkg.main) })
420
+ }
421
+ if (pkg?.karin?.apps?.length) {
422
+ pkg.karin.apps.forEach((app) => {
423
+ fs.readdirSync(`./node_modules/${name}/${app}`).forEach((name) => {
424
+ /** 忽略非js */
425
+ if (!name.endsWith('.js')) { return }
426
+ const dir = `${name}/${app}`
427
+ list.push({ dir, name })
428
+ })
422
429
  })
423
- })
430
+ }
424
431
  }
425
432
  } catch { }
426
433
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-karin",
3
- "version": "0.6.25",
3
+ "version": "0.6.26",
4
4
  "private": false,
5
5
  "description": "基于 Kritor 进行开发的nodejs机器人框架",
6
6
  "homepage": "https://github.com/KarinJS/Karin",