Skip to content

Commit

Permalink
feat: allow runners without conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
innocenzi committed Jul 8, 2022
1 parent 483fbce commit fa937fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function run(options: Options = []): Plugin {
debug('Resolved options:', resolvedOptions)

resolvedOptions.input.forEach((runner) => {
if (runner.startup === true) {
if (runner.startup === true || runner.condition === undefined) {
handleRunnerCommand(resolvedOptions, runner)
}
})
Expand All @@ -69,7 +69,7 @@ function handleReload(options: ResolvedRunOptions, parameters: RunnerHandlerPara
const file = parameters.file.replaceAll('\\', '/')

options.input.forEach((runner) => {
if (!runner.condition(file)) {
if (!runner.condition?.(file)) {
return
}

Expand Down
8 changes: 5 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ export interface Runner {
*/
name: string

/** Whether to run when starting the dev server or building for production. */
/**
* Whether to run when starting the dev server or building for production.
*/
startup?: boolean

/**
* Condition for the handler to run.
* Condition for the handler to run when a file changes.
*/
condition: (file: string) => boolean
condition?: (file: string) => boolean

/**
* Executed when a watched file meets the condition.
Expand Down

0 comments on commit fa937fb

Please sign in to comment.