Skip to content

Commit

Permalink
chore: print warning logs about overwritten workflows (#114)
Browse files Browse the repository at this point in the history
* chore: print warning logs about overwritten workflows

* Update readme.md

* Update readme.md

Co-authored-by: Maciej Stosio <[email protected]>

---------

Co-authored-by: Maciej Stosio <[email protected]>
  • Loading branch information
km1chno and maciekstosio committed Sep 19, 2024
1 parent 46e637e commit e9199f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ then select the setup that matches your project - `npx setup-ci` generates workf

If your project has a monorepo structure, run the script from the root directory of the app for which you want to set up workflows.

> [!WARNING]
> If you re-run `npx setup-ci` in the same project or already have some workflows set up manually, they might get overwritten. Therefore, we recommend running the script with no uncommitted changes, so you can easily inspect the diff after script execution.
## 💡 Demo

Say we want to set up GitHub actions that run Typescript and Prettier checks on our project every time we create or push to an existing Pull Request.
Expand Down
6 changes: 6 additions & 0 deletions src/extensions/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ module.exports = (toolbox: CycliToolbox) => {
workflowFileName
)

if (toolbox.filesystem.exists(target)) {
toolbox.interactive.warning(
`Workflow file ${workflowFileName} already exists and will be overwritten.`
)
}

toolbox.filesystem.write(target, workflowString)

toolbox.interactive.step(`Created ${workflowFileName} workflow file.`)
Expand Down

0 comments on commit e9199f6

Please sign in to comment.