hubot 11.0.1 → 11.0.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/Robot.mjs +8 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hubot",
3
- "version": "11.0.1",
3
+ "version": "11.0.3",
4
4
  "author": "hubot",
5
5
  "keywords": [
6
6
  "github",
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 ?? '') ?? '.mjs'
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
- const adapterPathInCurrentWorkingDirectory = this.adapterName
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.
@@ -549,7 +544,7 @@ class Robot {
549
544
  let currentSection = null
550
545
  let nextSection
551
546
 
552
- this.logger.debug(`Parsing help for ${path}`)
547
+ this.logger.debug(`Parsing help for ${filePath}`)
553
548
 
554
549
  for (let i = 0, line; i < lines.length; i++) {
555
550
  line = lines[i]
@@ -573,7 +568,7 @@ class Robot {
573
568
  }
574
569
 
575
570
  if (currentSection === null) {
576
- this.logger.info(`${path} is using deprecated documentation syntax`)
571
+ this.logger.info(`${filePath} is using deprecated documentation syntax`)
577
572
  scriptDocumentation.commands = []
578
573
  for (let i = 0, line, cleanedLine; i < lines.length; i++) {
579
574
  line = lines[i]