From 91f4fb30581479702267f2ff96ab2f309ae86bab Mon Sep 17 00:00:00 2001 From: worm Date: Mon, 2 Jan 2023 15:38:38 -0800 Subject: [PATCH] It looks like a export request is successfully made, but I get an error. Might need to introduce delay --- log | 1 + main.js | 19 ++----------------- validate-user-input.mjs | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 17 deletions(-) create mode 100644 validate-user-input.mjs diff --git a/log b/log index e69de29..58a5215 100644 --- a/log +++ b/log @@ -0,0 +1 @@ +The plan ID is plan-UiFnw8QxVkotVrev diff --git a/main.js b/main.js index 817aa33..a2f1c6f 100644 --- a/main.js +++ b/main.js @@ -1,25 +1,10 @@ import { normalized_config } from "./normalize-config.js"; import { get_run_details, create_plan_export } from "./tfc-api-functions.mjs"; +import { runidNotProvided, runIdPrefixCheckFail } from "./validate-user-input.mjs"; const my_config = await normalized_config; -// TODO: Split all this run verification clutter out into a separate module -// verify that a run_id was provided to the program -const runid_provided = run_id => { - return (run_id ? true : false); -} - -// Add negation function for readability (no 'unless' in js) -const runidNotProvided = run_id => { - return !runid_provided(run_id); -} - -// Check for prefix indicating a valid run id -const startsWithRun = run_id => { - return run_id.startsWith("run-"); -} - -if(runidNotProvided(my_config.run_id) || !startsWithRun(my_config.run_id)){ +if(runidNotProvided(my_config.run_id) || runIdPrefixCheckFail(my_config.run_id)){ throw new Error("A valid RunID must be provided. Please check that the supplied runID is valid"); } diff --git a/validate-user-input.mjs b/validate-user-input.mjs new file mode 100644 index 0000000..d89a49c --- /dev/null +++ b/validate-user-input.mjs @@ -0,0 +1,19 @@ +// verify that a run_id was provided to the program + const runid_provided = run_id => { + return (run_id ? true : false); +} + +// Add negation function for readability (no 'unless' in js) +export const runidNotProvided = run_id => { + return !runid_provided(run_id); +} + +// Check for prefix indicating a valid run id + const startsWithRun = run_id => { + return run_id.startsWith("run-"); +} + +// Add negation function for readability (no 'unless' in js) +export const runIdPrefixCheckFail = run_id => { + return !startsWithRun(run_id); +} \ No newline at end of file