mirror of
https://github.com/toddbluhm/env-cmd.git
synced 2025-12-08 18:23:33 +00:00
25 lines
792 B
TypeScript
25 lines
792 B
TypeScript
/* eslint @typescript-eslint/no-non-null-assertion: 0 */
|
|
import { assert } from 'chai'
|
|
import { expandEnvs } from '../src/expand-envs'
|
|
|
|
describe('expandEnvs', (): void => {
|
|
const envs = {
|
|
notvar: 'this is not used',
|
|
dollar: 'money',
|
|
PING: 'PONG',
|
|
IP1: '127.0.0.1',
|
|
THANKSFORALLTHEFISH: 42,
|
|
BRINGATOWEL: true,
|
|
}
|
|
const args = ['notvar', '$dollar', '\\$notvar', '-4', '$PING', '$IP1', '\\$IP1', '$NONEXIST']
|
|
const argsExpanded = ['notvar', 'money', '\\$notvar', '-4', 'PONG', '127.0.0.1', '\\$IP1', '$NONEXIST']
|
|
|
|
it('should replace environment variables in args', (): void => {
|
|
const res = args.map(arg => expandEnvs(arg, envs))
|
|
assert.sameOrderedMembers(res, argsExpanded)
|
|
for (const arg of args) {
|
|
assert.typeOf(arg, 'string')
|
|
}
|
|
})
|
|
})
|