Skip to content

Commit 0992347

Browse files
committed
Set tests’ env. variable using dotenv
[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
1 parent d887401 commit 0992347

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules/
22
coverage/
3+
.env

Makefile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
test: node_modules
2+
test: node_modules .env
33
npm test
44

55
coverage: coverage/lcov.info
@@ -10,7 +10,25 @@ coveralls: coverage/lcov.info
1010

1111
.PHONY: test coverage coveralls
1212

13-
coverage/lcov.info: node_modules package.json oauth-1.0a.js test/*.js test/**/*.js test/mocha.opts
13+
.env:
14+
@echo "BITBUCKET_CONSUMER_PUBLIC=" > $@
15+
@echo "BITBUCKET_CONSUMER_SECRET=" >> $@
16+
@echo "" >> $@
17+
@echo "FLICKR_CONSUMER_key=" >> $@
18+
@echo "FLICKR_CONSUMER_SECRET=" >> $@
19+
@echo "" >> $@
20+
@echo "LINKEDIN_CONSUMER_PUBLIC=" >> $@
21+
@echo "LINKEDIN_CONSUMER_SECRET=" >> $@
22+
@echo "" >> $@
23+
@echo "OPENBANK_CONSUMER_PUBLIC=" >> $@
24+
@echo "OPENBANK_CONSUMER_SECRET=" >> $@
25+
@echo "" >> $@
26+
@echo "TWITTER_CONSUMER_PUBLIC=" >> $@
27+
@echo "TWITTER_CONSUMER_SECRET=" >> $@
28+
@echo "TWITTER_TOKEN_PUBLIC=" >> $@
29+
@echo "TWITTER_TOKEN_SECRET=" >> $@
30+
31+
coverage/lcov.info: node_modules package.json oauth-1.0a.js .env test/*.js test/**/*.js test/mocha.opts
1432
node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly
1533

1634
node_modules: package.json

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"devDependencies": {
2323
"chai": "^4.1.2",
2424
"coveralls": "^3.0.0",
25+
"dotenv": "^4.0.0",
2526
"istanbul": "^0.4.5",
2627
"mocha": "^4.0.1",
2728
"request": "~2.33.0"

test/mocha.opts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
--recursive
22
--reporter spec
3+
--require dotenv/config
34
--slow 1

0 commit comments

Comments
 (0)