Skip to content

Commit 35f49e9

Browse files
committed
➕ Support dotenv
1 parent 1a8b374 commit 35f49e9

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v4.6.0
4+
rev: v5.0.0
55
hooks:
66
- id: check-added-large-files
77
- id: fix-byte-order-marker
@@ -37,23 +37,23 @@ repos:
3737
args:
3838
- --msg-filename
3939
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
40-
rev: 2.7.3
40+
rev: 3.0.3
4141
hooks:
4242
- id: editorconfig-checker
4343
- repo: https://github.com/jumanjihouse/pre-commit-hooks
4444
rev: 3.0.0
4545
hooks:
4646
- id: check-mailmap
4747
- repo: https://github.com/rhysd/actionlint
48-
rev: v1.7.1
48+
rev: v1.7.3
4949
hooks:
5050
- id: actionlint
5151
- repo: https://github.com/adrienverge/yamllint
5252
rev: v1.35.1
5353
hooks:
5454
- id: yamllint
5555
- repo: https://github.com/executablebooks/mdformat
56-
rev: 0.7.17
56+
rev: 0.7.18
5757
hooks:
5858
- id: mdformat
5959
additional_dependencies:
@@ -67,7 +67,7 @@ repos:
6767
- mdformat-config
6868
- mdformat-web
6969
- repo: https://github.com/DavidAnson/markdownlint-cli2
70-
rev: v0.13.0
70+
rev: v0.14.0
7171
hooks:
7272
- id: markdownlint-cli2
7373
additional_dependencies:

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,23 @@ require"code-stats".setup({
7676
})
7777
```
7878

79+
For compatibility for
80+
[code-stats-zsh](https://gitlab.com/code-stats/code-stats-zsh) and
81+
[code-stats-bash](https://github.com/Freed-Wu/code-stats-bash), the following is
82+
also OK:
83+
84+
```lua
85+
require"code-stats".setup({
86+
dotenv = "/the/path/of/codestats.sh"
87+
})
88+
```
89+
90+
`/the/path/of/codestats.sh`:
91+
92+
```sh
93+
CODESTATS_API_KEY=XXXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
94+
```
95+
7996
## Related Projects
8097

8198
- [code-stats-vim](https://gitlab.com/code-stats/code-stats-vim)

code-stats.nvim-scm-1.rockspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ description = {
1616
license = 'GPL-3.0'
1717
}
1818

19-
dependencies = { 'lua >= 5.1', 'lua-requests' }
19+
dependencies = { 'lua >= 5.1', 'lua-requests', 'lua-dotenv' }
2020

2121
test_dependencies = { }
2222

lua/code-stats.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,11 @@ local M = {
696696
---@param conf table
697697
function M.setup(conf)
698698
M = vim.tbl_deep_extend("keep", conf, M)
699+
if conf.dotenv then
700+
local dotenv = require "lua-dotenv"
701+
dotenv.load_dotenv(conf.dotenv)
702+
M.args.headers['X-API-Token'] = dotenv.get('CODESTATS_API_KEY')
703+
end
699704
end
700705

701706
---add xp

0 commit comments

Comments
 (0)