Skip to content

Commit

Permalink
fix(logs): Improved config loading and logging from env
Browse files Browse the repository at this point in the history
+ Add package scripts for starting local bot
  • Loading branch information
timkinnane committed Mar 28, 2018
1 parent e509c9b commit 74c9240
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -37,7 +37,9 @@
"test:package": "preview && mocha 'src/*.spec.ts'",
"docs": "rimraf ./docs/* && typedoc --options ./typedoc.json ./src",
"prebuild": "npm run test",
"build": "rimraf ./dist/* && tsc && npm run test:package && npm run docs"
"build": "rimraf ./dist/* && tsc && npm run test:package && npm run docs",
"local": "ts-node -r dotenv/config src/start",
"start": "node -r dotenv/config dist/start"
},
"husky": {
"hooks": {
Expand Down
3 changes: 0 additions & 3 deletions src/index.ts
Expand Up @@ -16,9 +16,6 @@ import * as bot from './lib/bot'
import * as logger from './lib/logger'
import * as middleware from './lib/middleware'

/** Use `dotenv` to load local env settings from `.env` file in development */
if (process.env.NODE_ENV === 'development') require('dotenv').config()

export {
argv,
bot,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/argv.ts
Expand Up @@ -55,7 +55,7 @@ export function getConfig () {
process.exit(1)
})
.argv
const config: any = []
const config: any = {}
for (let key of Object.keys(argv)) {
if (optionsFilterKeys.indexOf(key) !== -1) {
config[key] = argv[key]
Expand Down
4 changes: 2 additions & 2 deletions src/lib/bot.ts
Expand Up @@ -30,9 +30,9 @@ export const events = new EventEmitter()
* bbot.bot.start()
*/
export async function start (opts?: IOptions) {
logger.info('Bleep Bloop... starting up ~(O_O)~')
logger.info(`Starting up ${config.name}... bleep bloop ~(O_O)~`)
Object.assign(config, opts)
logger.info('Using config:', config)
logger.info('Using config...', config)
started = true
events.emit('ready')
return exports
Expand Down
1 change: 0 additions & 1 deletion test/mocha.opts
@@ -1,4 +1,3 @@
--require dotenv/config
--require ts-node/register
--require source-map-support/register
--recursive
Expand Down

0 comments on commit 74c9240

Please sign in to comment.