initial commit
This commit is contained in:
50
node_modules/vite-plugin-checker/dist/esm/Checker.js
generated
vendored
Normal file
50
node_modules/vite-plugin-checker/dist/esm/Checker.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
import invariant from "tiny-invariant";
|
||||
import { isInVitestEntryThread, isMainThread } from "./utils.js";
|
||||
import { createScript } from "./worker.js";
|
||||
if (!(isMainThread || isInVitestEntryThread)) {
|
||||
process.stdout.isTTY = true;
|
||||
}
|
||||
class Checker {
|
||||
static log(...args) {
|
||||
this.logger.forEach((fn) => fn(...args));
|
||||
}
|
||||
constructor({ name, absFilePath, createDiagnostic, build }) {
|
||||
this.name = name;
|
||||
this.absFilePath = absFilePath;
|
||||
this.build = build;
|
||||
this.createDiagnostic = createDiagnostic;
|
||||
this.build = build;
|
||||
}
|
||||
prepare() {
|
||||
const script = createScript({
|
||||
absFilename: this.absFilePath,
|
||||
buildBin: this.build.buildBin,
|
||||
serverChecker: { createDiagnostic: this.createDiagnostic }
|
||||
});
|
||||
this.script = script;
|
||||
return script;
|
||||
}
|
||||
initMainThread() {
|
||||
invariant(this.script, `script should be created in 'prepare', but got ${this.script}`);
|
||||
if (isMainThread || isInVitestEntryThread) {
|
||||
const createServeAndBuild = this.script.mainScript();
|
||||
return createServeAndBuild;
|
||||
}
|
||||
return;
|
||||
}
|
||||
initWorkerThread() {
|
||||
invariant(this.script, `script should be created in 'prepare', but got ${this.script}`);
|
||||
if (!(isMainThread || isInVitestEntryThread)) {
|
||||
this.script.workerScript();
|
||||
}
|
||||
}
|
||||
}
|
||||
Checker.logger = [
|
||||
(...args) => {
|
||||
console.log(args[0].payload);
|
||||
}
|
||||
];
|
||||
export {
|
||||
Checker
|
||||
};
|
||||
//# sourceMappingURL=Checker.js.map
|
||||
Reference in New Issue
Block a user