Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Help flag issue #608

Merged
merged 8 commits into from
Apr 11, 2024
2 changes: 1 addition & 1 deletion src/__tests__/unit/util/args.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ describe('util/args: ', () => {
const result = parseArgs();

expect(info).toHaveBeenCalledWith(HELP);
expect(result).toEqual(undefined);
expect(result).toEqual({});
});

it('returns manifest and output path.', () => {
Expand Down
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ const impactEngine = async () => {
const options = parseArgs();

if (options) {
manushak marked this conversation as resolved.
Show resolved Hide resolved
if (Object.keys(options).length === 0) {
return;
}

const {inputPath, outputPath, paramPath} = options;

const {tree, context, parameters} = await load(inputPath, paramPath);
const {tree, context, parameters} = await load(inputPath!, paramPath);
parameterize.combine(context.params, parameters);
const pluginStorage = await initalize(context.initialize.plugins);
const computedTree = await compute(tree, {context, pluginStorage});
Expand Down
6 changes: 6 additions & 0 deletions src/types/process-args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ export interface ManifestProcessArgs {
'override-params'?: string;
help?: boolean;
}

export interface ProcessArgsOutputs {
inputPath?: string;
outputPath?: string;
paramPath?: string;
}
6 changes: 3 additions & 3 deletions src/util/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {ERRORS} from './errors';

import {CONFIG, STRINGS} from '../config';

import {ManifestProcessArgs} from '../types/process-args';
import {ManifestProcessArgs, ProcessArgsOutputs} from '../types/process-args';

const {CliInputError} = ERRORS;

Expand Down Expand Up @@ -50,7 +50,7 @@ const prependFullFilePath = (filePath: string) => {
* If it is, then returns object containing full path.
* 4. If params are missing or invalid, then rejects with `CliInputError`.
*/
export const parseArgs = () => {
export const parseArgs = (): ProcessArgsOutputs => {
const {
manifest,
output,
Expand All @@ -60,7 +60,7 @@ export const parseArgs = () => {

if (help) {
console.info(HELP);
return;
return {};
}

if (manifest) {
Expand Down
Loading