Skip to content

Commit

Permalink
build: name the main file like the repo
Browse files Browse the repository at this point in the history
Looking into htop is way more helpful then to identify the given process.
  • Loading branch information
EdJoPaTo committed Aug 30, 2023
1 parent e792909 commit 6c1e2f2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ COPY wikidata-items.yaml ./
COPY --from=builder /build/dist ./

ENTRYPOINT ["node", "--enable-source-maps"]
CMD ["index.js"]
CMD ["wikidata-telegram-bot.js"]
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"url": "https://edjopato.de"
},
"scripts": {
"start": "tsc --sourceMap && node --enable-source-maps dist/index.js",
"start": "tsc --sourceMap && node --enable-source-maps dist/wikidata-telegram-bot.js",
"test": "tsc --sourceMap && xo"
},
"type": "module",
Expand Down Expand Up @@ -39,8 +39,7 @@
"xo": {
"rules": {
"@typescript-eslint/naming-convention": "off",
"n/file-extension-in-import": "off",
"n/prefer-global/process": "off"
"n/file-extension-in-import": "off"
}
}
}
9 changes: 4 additions & 5 deletions source/index.ts → source/wikidata-telegram-bot.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {env} from 'node:process';
import {readFileSync} from 'node:fs';
import {Bot, session} from 'grammy';
import {FileAdapter} from '@grammyjs/storage-file';
Expand All @@ -11,9 +12,7 @@ import {bot as locationSearch} from './location-search.js';
import {menu as languageMenu} from './language-menu.js';
import type {Context, Session} from './bot-generics.js';

(process as any).title = 'wikidata-tgbot';

const token = process.env['BOT_TOKEN'];
const token = env['BOT_TOKEN'];
if (!token) {
throw new Error(
'You have to provide the bot-token from @BotFather via environment variable (BOT_TOKEN)',
Expand All @@ -28,7 +27,7 @@ export const i18n = new I18n({

const twb = new TelegrafWikibase({
contextKey: 'wd',
logQueriedEntityIds: process.env['NODE_ENV'] !== 'production',
logQueriedEntityIds: env['NODE_ENV'] !== 'production',
userAgent: 'EdJoPaTo/wikidata-telegram-bot',
});
const wikidataResourceKeyYaml = readFileSync('wikidata-items.yaml', 'utf8');
Expand Down Expand Up @@ -68,7 +67,7 @@ bot.use(async (ctx, next) => {
bot.use(i18n.middleware());
bot.use(twb.middleware());

if (process.env['NODE_ENV'] !== 'production') {
if (env['NODE_ENV'] !== 'production') {
bot.use(generateUpdateMiddleware());
}

Expand Down

0 comments on commit 6c1e2f2

Please sign in to comment.