clean_app_src_folder.js 617 B

123456789101112131415161718192021
  1. const fs = require('fs-extra');
  2. const path = require('path');
  3. const appFolderPath = path.join(__dirname, './outApp/HelloWorld-win32-x64/resources/app/src');
  4. // 检查文件夹是否存在
  5. fs.pathExists(appFolderPath)
  6. .then((exists) => {
  7. if (exists) {
  8. // 删除文件夹
  9. return fs.remove(appFolderPath);
  10. }
  11. console.log(appFolderPath + ' 文件夹不存在,无需删除。');
  12. return Promise.resolve();
  13. })
  14. .then(() => {
  15. console.log(appFolderPath + ' 文件夹已成功删除。');
  16. })
  17. .catch((err) => {
  18. console.error('删除 ' + appFolderPath + ' 文件夹时出错:', err);
  19. });