21 lines
649 B
TypeScript
21 lines
649 B
TypeScript
/*
|
|
* 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
|
|
*/
|
|
|
|
/* eslint-disable no-process-env */
|
|
import { Option, OptionValue } from '../Option';
|
|
import { OptionSource } from './OptionSource';
|
|
|
|
export class EnvSource extends OptionSource {
|
|
public async parse (opt: Option, val:OptionValue): Promise<void> {
|
|
if (
|
|
typeof opt.env !== 'undefined'
|
|
&& typeof process.env[opt.env] !== 'undefined'
|
|
)
|
|
await this.assign_arg (opt, val, process.env[opt.env]);
|
|
}
|
|
}
|