-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Refactor clean command to have individual cleanup contexts
- Loading branch information
1 parent
3133e4f
commit e2a5fd3
Showing
3 changed files
with
49 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Command } from 'commander'; | ||
import { projectConfig } from '../../config/project'; | ||
import { deletePath } from '../../utils/file-system'; | ||
import log from '../../utils/log'; | ||
import sharedOptions from '../../utils/shared-options'; | ||
|
||
export const cleanDotEnvCommand = () => { | ||
const command = new Command(); | ||
command | ||
.name('dot-env') | ||
.summary('Cleanup repositories dot env files (.env).') | ||
.description( | ||
'Removes the dot env files (.env) for all the DEMS-managed repositories configured.', | ||
) | ||
.addOption(sharedOptions.force()) | ||
.action(async (options) => { | ||
const config = projectConfig(); | ||
log.info('Removing dot env files for managed repositories...'); | ||
|
||
if (options.force) { | ||
log.warning('User interactivity disabled due to --force flag.'); | ||
} | ||
|
||
for (const repo of Object.values(config.paths.repos)) { | ||
await deletePath({ | ||
path: `${repo}/.env`, | ||
force: options.force, | ||
}); | ||
} | ||
|
||
log.success('dot env files (.env) removed for managed repositories.'); | ||
}); | ||
|
||
return command; | ||
}; | ||
|
||
export default cleanDotEnvCommand(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters