mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 00:47:01 +00:00
feature: cloudcmd: migrate to ESM
This commit is contained in:
parent
e8a81c49ea
commit
4533a25c6f
184 changed files with 339 additions and 388 deletions
27
server/env.js
Normal file
27
server/env.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import {env} from 'node:process';
|
||||
import snake from 'just-snake-case';
|
||||
|
||||
const up = (a) => a.toUpperCase();
|
||||
|
||||
export const bool = (name) => {
|
||||
const value = parse(name);
|
||||
|
||||
if (value === 'true')
|
||||
return true;
|
||||
|
||||
if (value === '1')
|
||||
return true;
|
||||
|
||||
if (value === 'false')
|
||||
return false;
|
||||
|
||||
if (value === '0')
|
||||
return false;
|
||||
};
|
||||
|
||||
export const parse = (name) => {
|
||||
const small = `cloudcmd_${snake(name)}`;
|
||||
const big = up(small);
|
||||
|
||||
return env[big] || env[small];
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue