hubot 11.0.0 → 11.0.1

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 +13 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hubot",
3
- "version": "11.0.0",
3
+ "version": "11.0.1",
4
4
  "author": "hubot",
5
5
  "keywords": [
6
6
  "github",
package/src/Robot.mjs CHANGED
@@ -329,20 +329,22 @@ class Robot {
329
329
  }
330
330
 
331
331
  async loadmjs (filePath) {
332
- const script = await import(pathToFileURL(filePath))
332
+ const forImport = this.prepareForImport(filePath)
333
+ const script = await import(forImport)
333
334
  if (typeof script?.default === 'function') {
334
335
  script.default(this)
335
336
  } else {
336
- this.logger.warning(`Expected ${filePath} to assign a function to export default, got ${typeof script}`)
337
+ this.logger.warning(`Expected ${filePath} (after preparing for import ${forImport}) to assign a function to export default, got ${typeof script}`)
337
338
  }
338
339
  }
339
340
 
340
341
  async loadjs (filePath) {
341
- const script = (await import(filePath)).default
342
+ const forImport = this.prepareForImport(filePath)
343
+ const script = (await import(forImport)).default
342
344
  if (typeof script === 'function') {
343
345
  script(this)
344
346
  } else {
345
- this.logger.warning(`Expected ${filePath} to assign a function to module.exports, got ${typeof script}`)
347
+ this.logger.warning(`Expected ${filePath} (after preparing for import ${forImport}) to assign a function to module.exports, got ${typeof script}`)
346
348
  }
347
349
  }
348
350
 
@@ -496,7 +498,7 @@ class Robot {
496
498
  } else if (['.js', '.cjs'].includes(ext)) {
497
499
  this.adapter = await this.requireAdapterFrom(path.resolve(adapterPath))
498
500
  } else if (['.mjs'].includes(ext)) {
499
- this.adapter = await this.importAdapterFrom(pathToFileURL(path.resolve(adapterPath)).href)
501
+ this.adapter = await this.importAdapterFrom(path.resolve(adapterPath))
500
502
  } else {
501
503
  const adapterPathInCurrentWorkingDirectory = this.adapterName
502
504
  try {
@@ -520,7 +522,8 @@ class Robot {
520
522
  }
521
523
 
522
524
  async importAdapterFrom (adapterPath) {
523
- return await (await import(adapterPath)).default.use(this)
525
+ const forImport = this.prepareForImport(adapterPath)
526
+ return await (await import(forImport)).default.use(this)
524
527
  }
525
528
 
526
529
  // Public: Help Commands for Running Scripts.
@@ -670,6 +673,10 @@ class Robot {
670
673
  this.events.removeAllListeners()
671
674
  }
672
675
 
676
+ prepareForImport (filePath) {
677
+ return pathToFileURL(filePath)
678
+ }
679
+
673
680
  // Public: The version of Hubot from npm
674
681
  //
675
682
  // Returns a String of the version number.