版博士V2.0程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

73 行
2.2 KiB

  1. import { c as createBirpc } from './vendor-index.783e7f3e.js';
  2. import { workerId } from 'tinypool';
  3. import { g as getWorkerState } from './chunk-utils-global.fd174983.js';
  4. import { s as startViteNode, m as moduleCache, a as mockMap } from './chunk-runtime-mocker.3283818a.js';
  5. import { s as setupInspect } from './chunk-runtime-inspector.b1427a10.js';
  6. import { a as rpcDone } from './chunk-runtime-rpc.d6aa57f8.js';
  7. import 'node:url';
  8. import 'vite-node/client';
  9. import 'vite-node/utils';
  10. import 'pathe';
  11. import './vendor-index.bdee400f.js';
  12. import 'acorn';
  13. import 'node:module';
  14. import 'node:fs';
  15. import 'node:assert';
  16. import 'node:process';
  17. import 'node:path';
  18. import 'node:v8';
  19. import 'node:util';
  20. import '@vitest/runner/utils';
  21. import './chunk-paths.e36446b4.js';
  22. import '@vitest/utils';
  23. import './chunk-utils-base.b5ddfcc9.js';
  24. import '@vitest/spy';
  25. import 'node:inspector';
  26. function init(ctx) {
  27. if (typeof __vitest_worker__ !== "undefined" && ctx.config.threads && ctx.config.isolate)
  28. throw new Error(`worker for ${ctx.files.join(",")} already initialized by ${getWorkerState().ctx.files.join(",")}. This is probably an internal bug of Vitest.`);
  29. const { config, port, workerId: workerId$1 } = ctx;
  30. process.env.VITEST_WORKER_ID = String(workerId$1);
  31. process.env.VITEST_POOL_ID = String(workerId);
  32. globalThis.__vitest_environment__ = config.environment;
  33. globalThis.__vitest_worker__ = {
  34. ctx,
  35. moduleCache,
  36. config,
  37. mockMap,
  38. rpc: createBirpc(
  39. {},
  40. {
  41. eventNames: ["onUserConsoleLog", "onFinished", "onCollected", "onWorkerExit"],
  42. post(v) {
  43. port.postMessage(v);
  44. },
  45. on(fn) {
  46. port.addListener("message", fn);
  47. }
  48. }
  49. )
  50. };
  51. if (ctx.invalidates) {
  52. ctx.invalidates.forEach((fsPath) => {
  53. moduleCache.delete(fsPath);
  54. moduleCache.delete(`mock:${fsPath}`);
  55. });
  56. }
  57. ctx.files.forEach((i) => moduleCache.delete(i));
  58. }
  59. async function run(ctx) {
  60. const inspectorCleanup = setupInspect(ctx.config);
  61. try {
  62. init(ctx);
  63. const { run: run2, executor } = await startViteNode(ctx);
  64. await run2(ctx.files, ctx.config, ctx.environment, executor);
  65. await rpcDone();
  66. } finally {
  67. inspectorCleanup();
  68. }
  69. }
  70. export { run };