File tree Expand file tree Collapse file tree 2 files changed +69
-0
lines changed
Expand file tree Collapse file tree 2 files changed +69
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ local fs = require 'bee.filesystem'
22local util = require ' utility'
33local version = require ' version'
44
5+ require ' config.env'
6+
57local function getValue (value )
68 if value == ' true' or value == nil then
79 value = true
Original file line number Diff line number Diff line change 1+ -- Handles loading environment arguments
2+
3+ --- Convert a string to boolean
4+ --- @param v string
5+ local function strToBool (v )
6+ return v == " true"
7+ end
8+
9+ --- ENV args are defined here.
10+ ---- `name` is the ENV arg name
11+ ---- `key` is the value used to index `_G` for setting the argument
12+ ---- `converter` if present, will be used to convert the string value into another type
13+ --- @type { name : string , key : string , converter : fun ( value : string ): any } []
14+ local vars = {
15+ {
16+ name = " LLS_CHECK_LEVEL" ,
17+ key = " CHECKLEVEL" ,
18+ },
19+ {
20+ name = " LLS_CHECK_PATH" ,
21+ key = " CHECK" ,
22+ },
23+ {
24+ name = " LLS_CONFIG_PATH" ,
25+ key = " CONFIGPATH" ,
26+ },
27+ {
28+ name = " LLS_DOC_OUT_PATH" ,
29+ key = " DOC_OUT_PATH" ,
30+ },
31+ {
32+ name = " LLS_DOC_PATH" ,
33+ key = " DOC" ,
34+ },
35+ {
36+ name = " LLS_FORCE_ACCEPT_WORKSPACE" ,
37+ key = " FORCE_ACCEPT_WORKSPACE" ,
38+ converter = strToBool ,
39+ },
40+ {
41+ name = " LLS_LOCALE" ,
42+ key = " LOCALE" ,
43+ },
44+ {
45+ name = " LLS_LOG_LEVEL" ,
46+ key = " LOGLEVEL" ,
47+ },
48+ {
49+ name = " LLS_LOG_PATH" ,
50+ key = " LOGPATH" ,
51+ },
52+ {
53+ name = " LLS_META_PATH" ,
54+ key = " METAPATH" ,
55+ },
56+ }
57+
58+ for _ , var in ipairs (vars ) do
59+ local value = os.getenv (var .name )
60+ if value then
61+ if var .converter then
62+ value = var .converter (value )
63+ end
64+
65+ _G [var .key ] = value
66+ end
67+ end
You can’t perform that action at this time.
0 commit comments