console-app/lib/Sources/EnvSource.ts

21 lines
649 B
TypeScript
Raw Normal View History

2020-05-15 16:53:45 +02:00
/*
* Copyright (C) Sapphirecode - All Rights Reserved
* This file is part of console-app which is released under MIT.
* See file 'LICENSE' for full license details.
* Created by Timo Hocker <timo@scode.ovh>, May 2020
*/
2020-05-09 19:51:43 +02:00
/* eslint-disable no-process-env */
2020-06-09 21:03:10 +02:00
import { Option, OptionValue } from '../Option';
2020-05-09 19:51:43 +02:00
import { OptionSource } from './OptionSource';
export class EnvSource extends OptionSource {
2020-06-09 21:03:10 +02:00
public async parse (opt: Option, val:OptionValue): Promise<void> {
if (
typeof opt.env !== 'undefined'
2020-05-09 19:51:43 +02:00
&& typeof process.env[opt.env] !== 'undefined'
2020-06-09 21:03:10 +02:00
)
await this.assign_arg (opt, val, process.env[opt.env]);
2020-05-09 19:51:43 +02:00
}
}