vite-plugin-watch-and-run
Advanced tools
Comparing version 1.3.2 to 1.4.0
# @kitql/vite-plugin-watch-and-run | ||
## 1.4.0 | ||
### Minor Changes | ||
- [#399](https://github.com/jycouet/kitql/pull/399) | ||
[`7b0edf3`](https://github.com/jycouet/kitql/commit/7b0edf3c378f8c1494b360197834f45cdfe60636) | ||
Thanks [@jycouet](https://github.com/jycouet)! - remove quiet args in favor of logs to have a more | ||
granular control. | ||
### Patch Changes | ||
- Updated dependencies | ||
[[`7b0edf3`](https://github.com/jycouet/kitql/commit/7b0edf3c378f8c1494b360197834f45cdfe60636)]: | ||
- @kitql/helpers@0.8.3 | ||
## 1.3.2 | ||
@@ -4,0 +19,0 @@ |
@@ -16,5 +16,5 @@ import type { Plugin, ViteDevServer } from 'vite'; | ||
/** | ||
* Don't print anything extra to the console when an event is trigger | ||
* Tune what you want to print to the console. By default, everything. | ||
*/ | ||
quiet?: boolean; | ||
logs?: LogType[]; | ||
/** | ||
@@ -44,2 +44,3 @@ * run command (npm run gen for example!) | ||
export type KindWithPath = (typeof kindWithPath)[number]; | ||
export type LogType = 'trigger' | 'streamData' | 'streamError' | 'end'; | ||
export declare const kindWithoutPath: readonly ["all", "error", "raw", "ready"]; | ||
@@ -50,3 +51,3 @@ export type KindWithoutPath = (typeof kindWithoutPath)[number]; | ||
kind: WatchKind[]; | ||
quiet: boolean; | ||
logs: LogType[]; | ||
run: string | ((server: ViteDevServer) => void | Promise<void>); | ||
@@ -53,0 +54,0 @@ delay: number; |
@@ -21,3 +21,3 @@ import { spawn } from 'node:child_process'; | ||
name: paramRow.name, | ||
quiet: Boolean(paramRow.quiet), | ||
logs: paramRow.logs ?? ['trigger', 'streamData', 'streamError', 'end'], | ||
watch: paramRow.watch, | ||
@@ -73,12 +73,12 @@ shell: paramRow.shell ?? true, | ||
// print the message | ||
if (!info.quiet) { | ||
let message = `${green('✔')} Watch ${cyan(watchKind)}`; | ||
if (info.logs.includes('trigger')) { | ||
let message = [`Watch ${cyan(watchKind)}`]; | ||
if (info.watch && absolutePath) { | ||
message += green(' ' + absolutePath.replaceAll(process.cwd(), '')); | ||
message.push(green(absolutePath.replaceAll(process.cwd(), ''))); | ||
} | ||
if (typeof info.run === 'string') { | ||
message += ` and run ${green(info.run)} `; | ||
message.push(`and run ${green(info.run)}`); | ||
} | ||
message += ` ${cyan(info.delay + 'ms')}`; | ||
log.info(message); | ||
message.push(`${cyan(info.delay + 'ms')}`); | ||
log.success(message.join(' ')); | ||
} | ||
@@ -108,16 +108,28 @@ // Run after a delay | ||
//spit stdout to screen | ||
child.stdout.on('data', data => { | ||
process.stdout.write(formatLog(data.toString(), info.name ?? '')); | ||
}); | ||
if (info.logs.includes('streamData')) { | ||
child.stdout.on('data', data => { | ||
process.stdout.write(formatLog(data.toString(), info.name ?? '')); | ||
}); | ||
} | ||
//spit stderr to screen | ||
child.stderr.on('data', data => { | ||
process.stdout.write(formatLog(data.toString(), info.name ?? '')); | ||
}); | ||
if (info.logs.includes('streamError')) { | ||
child.stderr.on('data', data => { | ||
process.stdout.write(formatLog(data.toString(), info.name ?? '')); | ||
}); | ||
} | ||
child.on('close', code => { | ||
if (code === 0) { | ||
log.info(`${green('✔')} finished ${green('successfully')}`); | ||
if (info.logs.includes('end')) { | ||
const message = [`Finished`]; | ||
if (info.name) { | ||
message.push(`${magenta(info.name)}`); | ||
} | ||
if (code === 0) { | ||
message.push(green('successfully')); | ||
log.success(message.join(' ')); | ||
} | ||
else { | ||
message.push(`with some ${red('errors')}!`); | ||
log.error(message.join(' ')); | ||
} | ||
} | ||
else { | ||
log.error(`finished with some ${red('errors')}`); | ||
} | ||
info.isRunning = false; | ||
@@ -124,0 +136,0 @@ }); |
@@ -7,3 +7,3 @@ { | ||
], | ||
"version": "1.3.2", | ||
"version": "1.4.0", | ||
"license": "MIT", | ||
@@ -10,0 +10,0 @@ "type": "module", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22168
221