-
Notifications
You must be signed in to change notification settings - Fork 23
feat: Add cleanup option for exported .env file and refactor post-processing logic #28
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import core from "@actions/core"; | ||
| import fs from "fs/promises"; | ||
|
|
||
| const post = async () => { | ||
| try { | ||
| const fileOutputPath = core.getInput("file-output-path"); | ||
| const shouldClean = core.getBooleanInput("clean"); | ||
|
|
||
| if (shouldClean) { | ||
| try { | ||
| const filePath = `${process.env.GITHUB_WORKSPACE}${fileOutputPath}`; | ||
|
|
||
| try { | ||
| await fs.access(filePath); | ||
| await fs.unlink(filePath); | ||
| core.info(`Cleaned up exported file at ${filePath}`); | ||
| } catch (accessErr) { | ||
| core.debug(`File not found at ${filePath}, skipping cleanup`); | ||
| } | ||
| } catch (err) { | ||
| core.warning(`Failed to clean up file: ${(err as Error)?.message}`); | ||
| } | ||
| } else { | ||
| core.info("Cleanup is disabled, keeping exported file"); | ||
| } | ||
|
Comment on lines
+9
to
+25
|
||
| } catch (err) { | ||
| core.setFailed((err as Error)?.message); | ||
| } | ||
| }; | ||
|
|
||
| post(); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These nested try-catch blocks are unnecessary and make the code harder to read. The inner try-catch (lines 13-19) already handles file access errors gracefully, so the outer try-catch (lines 10-22) that wraps it provides no additional value. Consider removing the outer try-catch block and keeping only the inner one.