Skip to content

Commit

Permalink
Merge pull request #1640 from hubotio/windows-adapter-load-failure
Browse files Browse the repository at this point in the history
fix(robot): Loading an adapter from file peridically fails on Windows.
  • Loading branch information
joeyguerra authored Jun 10, 2023
2 parents 008e507 + 53b479a commit 141fb7d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/robot.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const EventEmitter = require('events').EventEmitter
const fs = require('fs')
const path = require('path')
const pathToFileURL = require('url').pathToFileURL

const async = require('async')
const pino = require('pino')
Expand Down Expand Up @@ -510,9 +511,9 @@ class Robot {
if (Array.from(HUBOT_DEFAULT_ADAPTERS).indexOf(this.adapterName) > -1) {
this.adapter = this.requireAdapterFrom(path.resolve(path.join(__dirname, 'adapters', this.adapterName)))
} else if (['.js', '.cjs', '.coffee'].includes(ext)) {
this.adapter = this.requireAdapterFrom(path.resolve(adapterPath))
this.adapter = this.requireAdapterFrom(pathToFileURL(path.resolve(adapterPath)).pathname)
} else if (['.mjs'].includes(ext)) {
this.adapter = await this.importAdapterFrom(path.resolve(adapterPath))
this.adapter = await this.importAdapterFrom(pathToFileURL(path.resolve(adapterPath)).href)
} else {
this.adapter = this.requireAdapterFrom(`hubot-${this.adapterName}`)
}
Expand Down

0 comments on commit 141fb7d

Please sign in to comment.