From 74c742b81edcc0a028e6de169909bcb092c74ad8 Mon Sep 17 00:00:00 2001 From: ljacobsson Date: Wed, 6 Dec 2023 18:22:18 +0100 Subject: [PATCH] feat: StepFunctions test state command :tada: --- package.json | 2 +- src/commands/stepfunctions/test-state.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 6bcbce2..dc47611 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "samp-cli", - "version": "1.0.65", + "version": "1.0.66", "description": "CLI tool for extended productivity with AWS Serverless Application Model (SAM)", "main": "index.js", "scripts": { diff --git a/src/commands/stepfunctions/test-state.js b/src/commands/stepfunctions/test-state.js index 3beef95..ae1cbbc 100644 --- a/src/commands/stepfunctions/test-state.js +++ b/src/commands/stepfunctions/test-state.js @@ -77,13 +77,15 @@ async function getInput(stateMachineArn, state, stateMachineType) { fs.mkdirSync(path.join(os.homedir(), '.samp-cli', 'state-tests'), { recursive: true }); } - const stateMachineStateFileExists = fs.existsSync(path.join(os.homedir(), '.samp-cli', 'state-tests', stateMachineArn)); + const fileName = stateMachineArn.replace(/:/g, "-"); + + const stateMachineStateFileExists = fs.existsSync(path.join(os.homedir(), '.samp-cli', 'state-tests', fileName)); if (!stateMachineStateFileExists) { - fs.writeFileSync(path.join(os.homedir(), '.samp-cli', 'state-tests', stateMachineArn), "{}"); + fs.writeFileSync(path.join(os.homedir(), '.samp-cli', 'state-tests', fileName), "{}"); } - const storedState = JSON.parse(fs.readFileSync(path.join(os.homedir(), '.samp-cli', 'state-tests', stateMachineArn), "utf8")); + const storedState = JSON.parse(fs.readFileSync(path.join(os.homedir(), '.samp-cli', 'state-tests', fileName), "utf8")); if (Object.keys(storedState).length > 0) { types = ["Latest input", ...types]; }