版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

40 lines
844 B

  1. import { render } from "cli-testing-library";
  2. import { resolve, dirname } from "node:path";
  3. import { fileURLToPath } from "node:url";
  4. const __dirname = dirname(fileURLToPath(import.meta.url));
  5. /**
  6. * @param {String} script
  7. * @param {Array} args
  8. * @param {Object} opts
  9. */
  10. export function renderScript(script, args = [], opts = {}) {
  11. const { cwd = __dirname } = opts;
  12. return render(
  13. resolve(__dirname, "../node_modules/.bin/nyc"),
  14. ["--silent", "node", script, ...args],
  15. {
  16. cwd,
  17. spawnOpts: {
  18. env: { ...process.env, NODE_ENV: "test" },
  19. },
  20. }
  21. );
  22. }
  23. /**
  24. * @param {Array} args
  25. * @param {Object} opts
  26. */
  27. export function renderPlop(args = [], opts = {}) {
  28. return renderScript(
  29. resolve(__dirname, "../instrumented/bin/plop.js"),
  30. args,
  31. opts
  32. );
  33. }
  34. export * from "cli-testing-library";