Skip to content

Commit

Permalink
feat: add force option for dico init
Browse files Browse the repository at this point in the history
  • Loading branch information
lihbr committed Jun 2, 2021
1 parent b8c3669 commit 540827b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ cli.command("whoami", "Display current user").action(async options => {
await commands.whoami(cli, options);
});

cli.command("init", "Init a dico in your project").action(async options => {
await middlewares.signedInOnly();
await commands.init(cli, options);
});
cli
.command("init", "Init a dico in your project")
.option("-f, --force", "Override existing `dico.config.json`")
.action(async options => {
await middlewares.signedInOnly();
await commands.init(cli, options);
});

cli.version(VERSION);
cli.help(commands.help);
Expand Down
4 changes: 2 additions & 2 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ const initConfig = {

export const init = async (
_: CAC,
__: { [key: string]: never }
options: { [key: string]: never }
): Promise<void> => {
if (dicojson.exists()) {
if (!options.force && dicojson.exists()) {
logger.error(messages.DicoJSONAlreadyExists, dicojson.getPath());
exit(1);
}
Expand Down

0 comments on commit 540827b

Please sign in to comment.