release.js 750 B

12345678910111213141516171819202122232425262728293031
  1. const fs = require('fs-extra');
  2. const path = require('path');
  3. const { execSync } = require('child_process');
  4. const pckg = require('../package.json');
  5. const distDir = path.resolve(__dirname, '../dist');
  6. const outDir = `${distDir}/release`;
  7. async function makeRelease(target) {
  8. const srcDir = `${distDir}/${target}`;
  9. if (await fs.pathExists(srcDir)) {
  10. const zipFile = `${outDir}/${pckg.name}-${pckg.version}-${target}.zip`;
  11. execSync(`zip -r ${zipFile} .`, {cwd: srcDir, stdio: 'inherit'});
  12. }
  13. }
  14. async function main() {
  15. try {
  16. await fs.emptyDir(outDir);
  17. await makeRelease('win');
  18. await makeRelease('linux');
  19. } catch(e) {
  20. console.error(e);
  21. process.exit(1);
  22. }
  23. }
  24. main();