min.js 900 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/electron
  2. const name = 'min';
  3. const {app} = require('electron');
  4. const fs = require('fs');
  5. const path = require('path');
  6. // Change command name.
  7. const fd = fs.openSync('/proc/self/comm', fs.constants.O_WRONLY);
  8. fs.writeSync(fd, name);
  9. fs.closeSync(fd);
  10. // Remove first command line argument (/usr/bin/electron).
  11. process.argv.splice(0, 1);
  12. // Set application paths.
  13. const appPath = path.join(path.dirname(__dirname), 'lib', name);
  14. const packageJson = require(path.join(appPath, 'package.json'));
  15. const productName = packageJson.productName;
  16. app.setAppPath(appPath);
  17. app.setDesktopName(name + '.desktop');
  18. app.setName(productName);
  19. app.setPath('userCache', path.join(app.getPath('cache'), productName));
  20. app.setPath('userData', path.join(app.getPath('appData'), productName));
  21. app.setVersion(packageJson.version);
  22. // Run the application.
  23. require('module')._load(appPath, module, true);