import { createProgram, parseCommandLine } from './helpers/utils'; import { CliCommandDefinition, CliCommandHandler, CliParsedCommandHandler, CliProgramDefinition, ParsedCliCommand } from '../src'; describe('Process Environment Variables', () => { const buildCmdDef: CliCommandDefinition = { name: 'build', description: 'my description', env: { TEST_ENV_VAR: 'test env val' }, arguments: [ { name: 'src', description: 'Source file' }, { name: 'dest', description: 'Desination File', isOptional: true, default: 'Default Value' }, ], options: [ { name: 'output', flag: '-o', description: 'output description', }, ] }; it('should set a process environment variable from vars defined in command definition', done => { const buildCmdHandler: CliCommandHandler = (args, options) => { expect(process.env.TEST_ENV_VAR).toEqual('test env val'); done(); } const def = createProgram('test1', buildCmdDef); def.commands[0].handler = buildCmdHandler; const p1 = parseCommandLine('build a b', def, '1.0.0'); p1.run(); }) })