From 82bbdbb3f494783f23e258ac2eb0596c58b58abf Mon Sep 17 00:00:00 2001 From: Joey Guerra Date: Wed, 22 May 2024 11:14:50 -0500 Subject: [PATCH] fix(Robot): warning function doesn't exist message when the regex starts with an anchor --- src/Adapter.mjs | 12 ++++++------ src/Robot.mjs | 8 ++++---- test/Robot_test.mjs | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Adapter.mjs b/src/Adapter.mjs index 4c8a0ad11..45fd15d82 100644 --- a/src/Adapter.mjs +++ b/src/Adapter.mjs @@ -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() } @@ -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) } @@ -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) } @@ -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) } @@ -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) } @@ -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) } } diff --git a/src/Robot.mjs b/src/Robot.mjs index 42dc216c2..3c911e93c 100644 --- a/src/Robot.mjs +++ b/src/Robot.mjs @@ -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) { @@ -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 } @@ -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 } diff --git a/test/Robot_test.mjs b/test/Robot_test.mjs index 860274a3f..ac41fc55d 100644 --- a/test/Robot_test.mjs +++ b/test/Robot_test.mjs @@ -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) } @@ -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) }