commit b946ead85a8b3952743288bf150ac86c641bfce6
parent fe83519567bcdac02d9b1414dcbefe4e5cab7068
Author: Demonstrandum <moi@knutsen.co>
Date: Tue, 26 May 2020 23:20:59 +0100
Use path relative to repository root.
Diffstat:
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/commands/code.ts b/lib/commands/code.ts
@@ -51,10 +51,11 @@ export default async (homescope : HomeScope) => {
if (expansion) return message.channel.send(`\`${p}${command}\``
+ `is an alias that expands to \`${p}${expansion}\`.`);
- const filename = `${process.cwd()}/lib/commands/${command}.ts`;
+ const filename = `lib/commands/${command}.ts`;
try {
- const source = read_file(filename).toString();
+ const source = read_file(`${process.cwd()}/${filename}`)
+ .toString();
const authors = await file_authors(filename);
const author_str = "\n**Authors**: " + Object.keys(authors)
.map(author => `(\`${authors[author]}\`) ${author}`)
@@ -78,8 +79,9 @@ export default async (homescope : HomeScope) => {
+ source.format(FORMATS.code_block, 'typescript')
+ author_str);
}
- } catch {
+ } catch (error) {
+ console.log(`Error in code.ts: ${error}`);
message.answer(`Source for \`${p}${command}\``
- + ` (\`${filename}\`), was not found.`);
+ + ` (\`${process.cwd()}/${filename}\`), was not found.`);
}
};