repack.js 657 B

12345678910111213141516171819202122
  1. // Use this script to regenerate these fixture files
  2. // using a new version of the asar package
  3. const asar = require('@electron/asar');
  4. const fs = require('node:fs');
  5. const os = require('node:os');
  6. const path = require('node:path');
  7. const archives = [];
  8. for (const child of fs.readdirSync(__dirname)) {
  9. if (child.endsWith('.asar')) {
  10. archives.push(path.resolve(__dirname, child));
  11. }
  12. }
  13. for (const archive of archives) {
  14. const tmp = fs.mkdtempSync(path.resolve(os.tmpdir(), 'asar-spec-'));
  15. asar.extractAll(archive, tmp);
  16. asar.createPackageWithOptions(tmp, archive, {
  17. unpack: fs.existsSync(archive + '.unpacked') ? '*' : undefined
  18. });
  19. }