Skip to content

Commit

Permalink
feat: StepFunctions test state command 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
ljacobsson committed Dec 6, 2023
1 parent c60c3df commit 74c742b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
8 changes: 5 additions & 3 deletions src/commands/stepfunctions/test-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down

0 comments on commit 74c742b

Please sign in to comment.