console-app/lib/Sources/EnvSource.ts
2020-05-15 16:53:45 +02:00

24 lines
732 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 { OptionProcess } from '../Option';
import { OptionSource } from './OptionSource';
export class EnvSource extends OptionSource {
public async parse (options: OptionProcess[]): Promise<void> {
await Promise.all (options.map ((opt) => {
if (
typeof opt.env !== 'undefined'
&& typeof process.env[opt.env] !== 'undefined'
)
return this.assign_arg (opt, process.env[opt.env]);
return Promise.resolve ();
}));
}
}