Skip to content

Commit

Permalink
fix: watch short option cannot enable watch mode (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
shulandmimi authored May 22, 2024
1 parent 7d082ef commit 0664f11
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ cli.option(
.option('--format [format]', 'choose one from "cjs" or "esm"')
.option('--external [...external]', 'external')
.option('--watch [...files]', 'watch files', { default: false })
.option('-w [...file]', 'watch files')
.option('-w [...file]', 'watch files', { default: false })
.option('--no-auto-external', 'if not found module, auto as external', { default: true })
.option('--exec [file]', 'custom execute command')
.option('-e [file]', 'custom execute command');
Expand All @@ -104,6 +104,7 @@ async function commonOptionsFromArgs(args: Record<string, any>): Promise<Partial
: undefined;
const execute =
isString(args.exec) || isString(args.e) ? args.exec || args.e : args.exec === true ? undefined : undefined;

return {
root,
target: args.target,
Expand All @@ -114,7 +115,7 @@ async function commonOptionsFromArgs(args: Record<string, any>): Promise<Partial
format: args.format,
config: configPath,
minify: args.minify,
noWatch: !args.watch,
noWatch: args.watch === false && args.w === false,
noExecute: args.exec === false,
watchFiles: [args.watch, args.w]
.flat()
Expand Down

0 comments on commit 0664f11

Please sign in to comment.