mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature: server: env: migrate to ESM
This commit is contained in:
parent
8de9bd0847
commit
d979e94927
5 changed files with 8 additions and 11 deletions
|
|
@ -8,7 +8,7 @@ import {createSimport} from 'simport';
|
||||||
import parse from 'yargs-parser';
|
import parse from 'yargs-parser';
|
||||||
import exit from '../server/exit.js';
|
import exit from '../server/exit.js';
|
||||||
import {createConfig, configPath} from '../server/config.js';
|
import {createConfig, configPath} from '../server/config.js';
|
||||||
import env from '../server/env.js';
|
import * as env from '../server/env.mjs';
|
||||||
import prefixer from '../server/prefixer.js';
|
import prefixer from '../server/prefixer.js';
|
||||||
import * as validate from '../server/validate.mjs';
|
import * as validate from '../server/validate.mjs';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import {fullstore} from 'fullstore';
|
||||||
import io from 'socket.io-client';
|
import io from 'socket.io-client';
|
||||||
import _forEachKey from 'for-each-key';
|
import _forEachKey from 'for-each-key';
|
||||||
import log from './log.mjs';
|
import log from './log.mjs';
|
||||||
import env from '../env.js';
|
import * as env from '../env.mjs';
|
||||||
|
|
||||||
const noop = () => {};
|
const noop = () => {};
|
||||||
const forEachKey = currify(_forEachKey);
|
const forEachKey = currify(_forEachKey);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,9 @@
|
||||||
'use strict';
|
import {env} from 'node:process';
|
||||||
|
import snake from 'just-snake-case';
|
||||||
const {env} = require('node:process');
|
|
||||||
const snake = require('just-snake-case');
|
|
||||||
|
|
||||||
const up = (a) => a.toUpperCase();
|
const up = (a) => a.toUpperCase();
|
||||||
|
|
||||||
module.exports.parse = parse;
|
export const bool = (name) => {
|
||||||
module.exports.bool = (name) => {
|
|
||||||
const value = parse(name);
|
const value = parse(name);
|
||||||
|
|
||||||
if (value === 'true')
|
if (value === 'true')
|
||||||
|
|
@ -22,7 +19,7 @@ module.exports.bool = (name) => {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
function parse(name) {
|
export const parse = (name) => {
|
||||||
const small = `cloudcmd_${snake(name)}`;
|
const small = `cloudcmd_${snake(name)}`;
|
||||||
const big = up(small);
|
const big = up(small);
|
||||||
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
const process = require('node:process');
|
const process = require('node:process');
|
||||||
const test = require('supertape');
|
const test = require('supertape');
|
||||||
const env = require('./env');
|
const env = require('./env.mjs');
|
||||||
|
|
||||||
test('cloudcmd: server: env: bool: upper case first', (t) => {
|
test('cloudcmd: server: env: bool: upper case first', (t) => {
|
||||||
const {
|
const {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
const process = require('node:process');
|
const process = require('node:process');
|
||||||
const test = require('supertape');
|
const test = require('supertape');
|
||||||
const env = require('../../server/env');
|
const env = require('../../server/env.mjs');
|
||||||
|
|
||||||
test('env: small', (t) => {
|
test('env: small', (t) => {
|
||||||
process.env.cloudcmd_hello = 'world';
|
process.env.cloudcmd_hello = 'world';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue