diff --git a/.devcontainer/.profile b/.devcontainer/.profile new file mode 100644 index 0000000..de94ce6 --- /dev/null +++ b/.devcontainer/.profile @@ -0,0 +1,4 @@ +# trust the repo +# fixes: +# - fatal: detected dubious ownership in repository at '/workspaces/bot-zero'. +git config --global --add safe.directory "$PWD" diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 09cc3a5..f680bdd 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,8 +1,15 @@ FROM mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye # Install the npm packages globally -RUN npm install -g npm@10.7.0 \ +RUN npm install -g npm@10.9.2 \ && npm install -g npm-check-updates COPY ./startup.sh / RUN chmod +x /startup.sh + +# Append the profile to the current .bashrc and .zshrc files +# this makes sure we keep the current behavior like colors and aliases +COPY ./.profile /tmp/.profile +RUN cat /tmp/.profile >> /home/node/.bashrc && \ + cat /tmp/.profile >> /home/node/.zshrc && \ + rm /tmp/.profile diff --git a/.devcontainer/startup.sh b/.devcontainer/startup.sh index 27a4b33..5cdc577 100644 --- a/.devcontainer/startup.sh +++ b/.devcontainer/startup.sh @@ -1,10 +1,5 @@ #!/bin/sh -# trust the repo -# fixes: -# - fatal: detected dubious ownership in repository at '/workspaces/bot-zero'. -git config --global --add safe.directory "$PWD" - # install NPM packages echo "" echo "Installing packages..." diff --git a/src/Bot.js b/src/Bot.js index 71b1bac..0f1ebad 100644 --- a/src/Bot.js +++ b/src/Bot.js @@ -125,7 +125,7 @@ class Bot { */ sendError(message, context) { context.robot.logger.error(message); - context.send(message); + this.adapter.responder.sendError(context, message); } /** diff --git a/src/adapters/Responder.js b/src/adapters/Responder.js index 321df52..6db9bd4 100644 --- a/src/adapters/Responder.js +++ b/src/adapters/Responder.js @@ -10,6 +10,15 @@ class Responder { send(res, title, image, link) { res.send(`${title}: ${image} - ${link}`); } + + /** + * Sends the error message to Hubot. + * @param {Hubot.Response} res the context. + * @param {string} message the error message. + */ + sendError(res, message) { + res.send(message); + } } exports.Responder = Responder;