版博士V2.0程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

1234567891011121314151617181920212223242526272829303132
  1. import fs from "node:fs";
  2. import { resolve, dirname } from "node:path";
  3. import { fileURLToPath } from "node:url";
  4. const __dirname = dirname(fileURLToPath(import.meta.url));
  5. export const getFileHelper = () => {
  6. let cleanupFile = null;
  7. afterEach(() => {
  8. if (!cleanupFile) return;
  9. try {
  10. fs.unlinkSync(cleanupFile);
  11. } catch (e) {}
  12. cleanupFile = null;
  13. });
  14. const getFilePath = async (path) => {
  15. const expectedFilePath = resolve(__dirname, path);
  16. cleanupFile = expectedFilePath;
  17. try {
  18. await fs.promises.unlink(cleanupFile);
  19. } catch (e) {}
  20. return expectedFilePath;
  21. };
  22. return {
  23. getFilePath,
  24. };
  25. };