Skip to content

Commit c21cdaf

Browse files
committed
Replace test config with .env config.
Less risk of publishing api details.
1 parent 54713ab commit c21cdaf

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

.env.template

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PUSHNOTICE_CHAT_ID=
2+
PUSHNOTICE_CHAT_SECRET=

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.env
12
*.sublime-project
23
*.sublime-workspace
34
node_modules

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
},
4444
"devDependencies": {
4545
"ava": "^4.1.0",
46+
"dotenv": "^16.0.0",
4647
"npm-check-updates": "^12.5.4",
4748
"xo": "^0.48.0"
4849
}

test.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
import process from 'node:process'
2+
import 'dotenv/config.js'// eslint-disable-line import/no-unassigned-import
13
import test from 'ava'
24
import pnotice from './index.js'
35

4-
// TODO: find a way to load config.chat from file?
56
const config = {
67
chat: {
7-
id: '',
8-
secret: '',
8+
id: process.env.PUSHNOTICE_CHAT_ID,
9+
secret: process.env.PUSHNOTICE_CHAT_SECRET,
910
},
1011
}
1112

12-
if (config.chat.id !== '') {
13+
if (config.chat.id) {
1314
console.log('Test file currently being run:', test.meta.file)
1415

1516
test('handle options.disabled = true', async (t) => {

0 commit comments

Comments
 (0)