hubot 6.0.0 → 7.0.0

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.js +10 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hubot",
3
- "version": "6.0.0",
3
+ "version": "7.0.0",
4
4
  "author": "hubot",
5
5
  "keywords": [
6
6
  "github",
package/src/robot.js CHANGED
@@ -504,7 +504,16 @@ class Robot {
504
504
  } else if (['.mjs'].includes(ext)) {
505
505
  this.adapter = await this.importAdapterFrom(pathToFileURL(path.resolve(adapterPath)).href)
506
506
  } else {
507
- this.adapter = this.requireAdapterFrom(`hubot-${this.adapterName}`)
507
+ const adapterPathInCurrentWorkingDirectory = this.adapterName
508
+ try {
509
+ this.adapter = this.requireAdapterFrom(adapterPathInCurrentWorkingDirectory)
510
+ } catch (err) {
511
+ if (err.name === 'SyntaxError' && err.message.includes('Cannot use import statement outside a module')) {
512
+ this.adapter = await this.importAdapterFrom(adapterPathInCurrentWorkingDirectory)
513
+ } else {
514
+ throw err
515
+ }
516
+ }
508
517
  }
509
518
  } catch (err) {
510
519
  this.logger.error(`Cannot load adapter ${adapterPath ?? '[no path set]'} ${this.adapterName} - ${err}`)