From 89100d5ae96f0110a7b9b2f8edf774af00cb7e47 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Fri, 1 Oct 2021 23:50:07 +0200 Subject: [PATCH] Get help information from arguments --- src/bin.ts | 1 + src/index.ts | 1 + src/run.ts | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bin.ts b/src/bin.ts index e72e547..664a305 100644 --- a/src/bin.ts +++ b/src/bin.ts @@ -38,6 +38,7 @@ run( verbose, processOpts: { stdio: ['inherit', 'ignore', 'inherit'] }, }, + program.helpInformation(), console.log.bind(console), ).catch((e) => { if (verbose) { diff --git a/src/index.ts b/src/index.ts index fd190a9..74c0594 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,6 +14,7 @@ export async function run(options: { verbose: false, processOpts: options.processOpts || { stdio: ['inherit', 'ignore', 'inherit'] }, }, + '', () => { } ); } diff --git a/src/run.ts b/src/run.ts index 4d20a62..9c8052f 100644 --- a/src/run.ts +++ b/src/run.ts @@ -1,5 +1,4 @@ // tslint:disable-next-line no-require-imports no-var-requires -import program from 'commander'; import * as path from 'path'; import * as Transform from './transform'; import { toolDefaults } from './types'; @@ -17,6 +16,7 @@ export async function run( verbose: boolean, processOpts: { stdio: [string, string, string] }, }, + helpInformation: string, log: (message?: any, ...optionalParams: any[]) => void ) { if (!options.outputFilePath) { @@ -85,7 +85,7 @@ export async function run( throw new Error('An error occurred when compiling your application with Elm 0.19.1.'); } } else { - throw new Error('Please provide a path to an Elm file.\n' + program.helpInformation()); + throw new Error(`Please provide a path to an Elm file.\n${helpInformation}`.trim()); } if (jsSource != '') { const transformed = await Transform.transform(