Skip to content

Commit

Permalink
Set tests’ env. variable using dotenv
Browse files Browse the repository at this point in the history
[dotenv] will append process.env variables set in the “.env” file. Note that it won’t override existing environment variable.


[dotenv]: https://github.com/motdotla/dotenv
  • Loading branch information
dinoboff committed Dec 23, 2017
1 parent d887401 commit 0992347
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
coverage/
.env
22 changes: 20 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

test: node_modules
test: node_modules .env
npm test

coverage: coverage/lcov.info
Expand All @@ -10,7 +10,25 @@ coveralls: coverage/lcov.info

.PHONY: test coverage coveralls

coverage/lcov.info: node_modules package.json oauth-1.0a.js test/*.js test/**/*.js test/mocha.opts
.env:
@echo "BITBUCKET_CONSUMER_PUBLIC=" > $@
@echo "BITBUCKET_CONSUMER_SECRET=" >> $@
@echo "" >> $@
@echo "FLICKR_CONSUMER_key=" >> $@
@echo "FLICKR_CONSUMER_SECRET=" >> $@
@echo "" >> $@
@echo "LINKEDIN_CONSUMER_PUBLIC=" >> $@
@echo "LINKEDIN_CONSUMER_SECRET=" >> $@
@echo "" >> $@
@echo "OPENBANK_CONSUMER_PUBLIC=" >> $@
@echo "OPENBANK_CONSUMER_SECRET=" >> $@
@echo "" >> $@
@echo "TWITTER_CONSUMER_PUBLIC=" >> $@
@echo "TWITTER_CONSUMER_SECRET=" >> $@
@echo "TWITTER_TOKEN_PUBLIC=" >> $@
@echo "TWITTER_TOKEN_SECRET=" >> $@

coverage/lcov.info: node_modules package.json oauth-1.0a.js .env test/*.js test/**/*.js test/mocha.opts
node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly

node_modules: package.json
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"devDependencies": {
"chai": "^4.1.2",
"coveralls": "^3.0.0",
"dotenv": "^4.0.0",
"istanbul": "^0.4.5",
"mocha": "^4.0.1",
"request": "~2.33.0"
Expand Down
1 change: 1 addition & 0 deletions test/mocha.opts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
--recursive
--reporter spec
--require dotenv/config
--slow 1

0 comments on commit 0992347

Please sign in to comment.