hubot 11.0.1 → 11.0.2
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.
- package/package.json +1 -1
- package/src/Robot.mjs +6 -11
package/package.json
CHANGED
package/src/Robot.mjs
CHANGED
|
@@ -491,7 +491,7 @@ class Robot {
|
|
|
491
491
|
return
|
|
492
492
|
}
|
|
493
493
|
this.logger.debug(`Loading adapter ${adapterPath ?? 'from npmjs:'} ${this.adapterName}`)
|
|
494
|
-
const ext = path.extname(adapterPath ?? '')
|
|
494
|
+
const ext = path.extname(adapterPath ?? '')
|
|
495
495
|
try {
|
|
496
496
|
if (Array.from(HUBOT_DEFAULT_ADAPTERS).indexOf(this.adapterName) > -1) {
|
|
497
497
|
this.adapter = await this.requireAdapterFrom(path.resolve(path.join(__dirname, 'adapters', `${this.adapterName}.mjs`)))
|
|
@@ -500,16 +500,7 @@ class Robot {
|
|
|
500
500
|
} else if (['.mjs'].includes(ext)) {
|
|
501
501
|
this.adapter = await this.importAdapterFrom(path.resolve(adapterPath))
|
|
502
502
|
} else {
|
|
503
|
-
|
|
504
|
-
try {
|
|
505
|
-
this.adapter = await this.requireAdapterFrom(adapterPathInCurrentWorkingDirectory)
|
|
506
|
-
} catch (err) {
|
|
507
|
-
if (err.name === 'SyntaxError') {
|
|
508
|
-
this.adapter = await this.importAdapterFrom(adapterPathInCurrentWorkingDirectory)
|
|
509
|
-
} else {
|
|
510
|
-
throw err
|
|
511
|
-
}
|
|
512
|
-
}
|
|
503
|
+
this.adapter = await this.importFromRepo(this.adapterName)
|
|
513
504
|
}
|
|
514
505
|
} catch (error) {
|
|
515
506
|
this.logger.error(`Cannot load adapter ${adapterPath ?? '[no path set]'} ${this.adapterName} - ${error}`)
|
|
@@ -526,6 +517,10 @@ class Robot {
|
|
|
526
517
|
return await (await import(forImport)).default.use(this)
|
|
527
518
|
}
|
|
528
519
|
|
|
520
|
+
async importFromRepo (adapterPath) {
|
|
521
|
+
return await (await import(adapterPath)).default.use(this)
|
|
522
|
+
}
|
|
523
|
+
|
|
529
524
|
// Public: Help Commands for Running Scripts.
|
|
530
525
|
//
|
|
531
526
|
// Returns an Array of help commands for running scripts.
|