Skip to content

Commit

Permalink
fix(Robot): warning function doesn't exist message when the regex sta…
Browse files Browse the repository at this point in the history
…rts with an anchor
  • Loading branch information
joeyguerra committed May 22, 2024
1 parent b66760f commit 82bbdbb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/Adapter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Adapter extends EventEmitter {
// Returns an Array of User objects.
// @deprecated Use @robot.brain
users () {
this.robot.logger.warning('@users() is going to be deprecated in 11.0.0 use @robot.brain.users()')
this.robot.logger.warn('@users() is going to be deprecated in 11.0.0 use @robot.brain.users()')
return this.robot.brain.users()
}

Expand All @@ -88,7 +88,7 @@ class Adapter extends EventEmitter {
// Returns a User instance of the specified user.
// @deprecated Use @robot.brain
userForId (id, options) {
this.robot.logger.warning('@userForId() is going to be deprecated in 11.0.0 use @robot.brain.userForId()')
this.robot.logger.warn('@userForId() is going to be deprecated in 11.0.0 use @robot.brain.userForId()')
return this.robot.brain.userForId(id, options)
}

Expand All @@ -97,7 +97,7 @@ class Adapter extends EventEmitter {
// Returns a User instance for the user with the specified name.
// @deprecated Use @robot.brain
userForName (name) {
this.robot.logger.warning('@userForName() is going to be deprecated in 11.0.0 use @robot.brain.userForName()')
this.robot.logger.warn('@userForName() is going to be deprecated in 11.0.0 use @robot.brain.userForName()')
return this.robot.brain.userForName(name)
}

Expand All @@ -108,7 +108,7 @@ class Adapter extends EventEmitter {
// Returns an Array of User instances matching the fuzzy name.
// @deprecated Use @robot.brain
usersForRawFuzzyName (fuzzyName) {
this.robot.logger.warning('@userForRawFuzzyName() is going to be deprecated in 11.0.0 use @robot.brain.userForRawFuzzyName()')
this.robot.logger.warn('@userForRawFuzzyName() is going to be deprecated in 11.0.0 use @robot.brain.userForRawFuzzyName()')
return this.robot.brain.usersForRawFuzzyName(fuzzyName)
}

Expand All @@ -119,7 +119,7 @@ class Adapter extends EventEmitter {
// Returns an Array of User instances matching the fuzzy name.
// @deprecated Use @robot.brain
usersForFuzzyName (fuzzyName) {
this.robot.logger.warning('@userForFuzzyName() is going to be deprecated in 11.0.0 use @robot.brain.userForFuzzyName()')
this.robot.logger.warn('@userForFuzzyName() is going to be deprecated in 11.0.0 use @robot.brain.userForFuzzyName()')
return this.robot.brain.usersForFuzzyName(fuzzyName)
}

Expand All @@ -131,7 +131,7 @@ class Adapter extends EventEmitter {
// Returns a ScopedClient instance.
// @deprecated Use node.js fetch.
http (url) {
this.robot.logger.warning('@http() is going to be deprecated in 11.0.0 use @robot.http()')
this.robot.logger.warn('@http() is going to be deprecated in 11.0.0 use @robot.http()')
return this.robot.http(url)
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Robot.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ class Robot {
const name = this.name.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')

if (regexStartsWithAnchor) {
this.logger.warning('Anchors don’t work well with respond, perhaps you want to use \'hear\'')
this.logger.warning(`The regex in question was ${regex.toString()}`)
this.logger.warn('Anchors don’t work well with respond, perhaps you want to use \'hear\'')
this.logger.warn(`The regex in question was ${regex.toString()}`)
}

if (!this.alias) {
Expand Down Expand Up @@ -336,7 +336,7 @@ class Robot {
if (typeof script?.default === 'function') {
result = await script.default(this)
} else {
this.logger.warning(`Expected ${filePath} (after preparing for import ${forImport}) to assign a function to export default, got ${typeof script}`)
this.logger.warn(`Expected ${filePath} (after preparing for import ${forImport}) to assign a function to export default, got ${typeof script}`)
}
return result
}
Expand All @@ -348,7 +348,7 @@ class Robot {
if (typeof script === 'function') {
result = await script(this)
} else {
this.logger.warning(`Expected ${filePath} (after preparing for import ${forImport}) to assign a function to module.exports, got ${typeof script}`)
this.logger.warn(`Expected ${filePath} (after preparing for import ${forImport}) to assign a function to module.exports, got ${typeof script}`)
}
return result
}
Expand Down
4 changes: 2 additions & 2 deletions test/Robot_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ describe('Robot', () => {
describe('non-Function script', () => {
it('logs a warning for a .js file that does not export the correct API', async () => {
let wasCalled = false
robot.logger.warning = (...args) => {
robot.logger.warn = (...args) => {
wasCalled = true
assert.ok(args)
}
Expand All @@ -340,7 +340,7 @@ describe('Robot', () => {

it('logs a warning for a .mjs file that does not export the correct API', async () => {
let wasCalled = false
robot.logger.warning = (...args) => {
robot.logger.warn = (...args) => {
wasCalled = true
assert.ok(args)
}
Expand Down

0 comments on commit 82bbdbb

Please sign in to comment.