Commit 97272845 authored by mohoff's avatar mohoff Committed by Richard Crosby

fix: set runtimeEnv and dev script terminal output

parent 87b91ffb
Pipeline #22843 passed with stages
in 1 minute and 49 seconds
......@@ -23,11 +23,11 @@
"watch": "tsc --watch",
"clean": "rimraf build/",
"build": "tsc",
"dev:load:commonjs": "yarn build; echo 'Loaded Config:\n'; cross-env NODE_ENV=development time node scripts/dev/load-commonjs.js | jq .",
"dev:load:es6": "echo 'Loaded Config:\n'; cross-env NODE_ENV=development time ts-node --transpile-only scripts/dev/load-es6.ts | jq .",
"dev:load:commonjs": "yarn build; cross-env NODE_ENV=development time node scripts/dev/load-commonjs.js",
"dev:load:es6": "cross-env NODE_ENV=development time ts-node --transpile-only scripts/dev/load-es6.ts",
"dev:load": "yarn dev:load:es6",
"dev:load:watch": "nodemon --exec 'yarn dev:load:es6'",
"dev:validate": "echo 'Validation Result:\n'; cross-env NODE_ENV=development time ts-node --transpile-only scripts/dev/validate.ts",
"dev:validate": "cross-env NODE_ENV=development time ts-node --transpile-only scripts/dev/validate.ts",
"dev:validate:watch": "nodemon --exec 'yarn dev:validate'"
},
"devDependencies": {
......
// eslint-disable-next-line @typescript-eslint/no-var-requires
/* eslint-disable @typescript-eslint/no-var-requires */
const { inspect } = require('util')
const StrongConfig = require('../../lib')
const strongConfig = new StrongConfig({
......@@ -8,4 +9,6 @@ const strongConfig = new StrongConfig({
const config = strongConfig.load()
console.log(JSON.stringify(config))
console.log('\nLoaded Config:\n')
console.log(inspect(config, { colors: true, compact: false }))
console.log('\n')
import { inspect } from 'util'
import StrongConfig from '../../src'
const strongConfig = new StrongConfig({
......@@ -7,4 +8,6 @@ const strongConfig = new StrongConfig({
const config = strongConfig.load()
console.log(JSON.stringify(config))
console.log('\nLoaded Config:\n')
console.log(inspect(config, { colors: true, compact: false }))
console.log('\n')
......@@ -7,4 +7,6 @@ const strongConfig = new StrongConfig({
const validationResult = strongConfig.validate()
console.log('\nValidation result:\n')
console.log(validationResult)
console.log('\n')
......@@ -15,7 +15,7 @@ const mockedSubstitutedConfig = '{"field":"value","replaceMe":"PASTE"}'
const mockedHydratedConfig = {
...mockedConfig,
replaceMe: 'PASTE',
[mockedOptions.runtimeEnvName]: runtimeEnv,
runtimeEnv,
}
mockedSubstituteWithEnv.mockReturnValue(() => mockedSubstitutedConfig)
......@@ -34,7 +34,7 @@ describe('hydrateConfig()', () => {
it('adds runtimeEnv as top-level field', () => {
expect(hydrateConfigInited(mockedConfig)).toEqual(
expect.objectContaining({
[mockedOptions.runtimeEnvName]: runtimeEnv,
runtimeEnv,
})
)
})
......
......@@ -10,10 +10,10 @@ export type InnerHydrateFunction = (
export const hydrateConfig = (
runtimeEnv: string,
{ runtimeEnvName, substitutionPattern }: Options
{ substitutionPattern }: Options
): InnerHydrateFunction =>
R.compose(
R.assoc(runtimeEnvName, runtimeEnv),
R.assoc('runtimeEnv', runtimeEnv),
R.unary(JSON.parse),
substituteWithEnv(substitutionPattern),
R.unary(JSON.stringify)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment