package.js 802 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. const Fs = require('fire-fs');
  3. const Path = require('path');
  4. // adapter project path
  5. let projectPath = Editor.projectPath;
  6. if (!projectPath) {
  7. projectPath = Editor.Project.path;
  8. }
  9. let PATH = Path.join(projectPath, './assets/resources/i18n');
  10. let mount = function () {
  11. // 创建目录,保证目录存在
  12. Fs.ensureDirSync(PATH);
  13. };
  14. let unmount = function () {
  15. // 如果目录为空则删除目录
  16. if (!Fs.existsSync(PATH)) {
  17. return;
  18. }
  19. if (Fs.readdirSync(PATH).length === 0) {
  20. Fs.unlink(PATH);
  21. }
  22. };
  23. let metrics = function () {
  24. Editor.Metrics.trackEvent({
  25. category: 'Packages',
  26. label: 'i18n',
  27. action: 'Panel Open'
  28. }, null);
  29. };
  30. exports.mount = mount;
  31. exports.unmount = unmount;
  32. exports.metrics = metrics;