diff options
author | LinuxWizard42 <computerwizard@linuxmail.org> | 2022-10-12 22:54:37 +0300 |
---|---|---|
committer | LinuxWizard42 <computerwizard@linuxmail.org> | 2022-10-12 22:54:37 +0300 |
commit | 703e03aba33f234712206769f57717ba7d92d23d (patch) | |
tree | 0041f04ccb75bd5379c764e9fe42249fffe75fc3 /node_modules/electron/install.js | |
parent | ab6e257e6e9d9a483d7e86f220d8b209a2cd7753 (diff) | |
download | FlashRunner-703e03aba33f234712206769f57717ba7d92d23d.tar.gz FlashRunner-703e03aba33f234712206769f57717ba7d92d23d.tar.zst |
Added export_allowed file to make repository visible in cgit
Diffstat (limited to 'node_modules/electron/install.js')
-rw-r--r-- | node_modules/electron/install.js | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/node_modules/electron/install.js b/node_modules/electron/install.js new file mode 100644 index 0000000..3f59ce1 --- /dev/null +++ b/node_modules/electron/install.js @@ -0,0 +1,66 @@ +#!/usr/bin/env node + +var version = require('./package').version + +var fs = require('fs') +var os = require('os') +var path = require('path') +var extract = require('extract-zip') +var download = require('electron-download') + +var installedVersion = null +try { + installedVersion = fs.readFileSync(path.join(__dirname, 'dist', 'version'), 'utf-8').replace(/^v/, '') +} catch (ignored) { + // do nothing +} + +var platformPath = getPlatformPath() + +var electronPath = process.env.ELECTRON_OVERRIDE_DIST_PATH || path.join(__dirname, 'dist', platformPath) + +if (installedVersion === version && fs.existsSync(electronPath)) { + process.exit(0) +} + +// downloads if not cached +download({ + cache: process.env.electron_config_cache, + version: version, + platform: process.env.npm_config_platform, + arch: process.env.npm_config_arch, + strictSSL: process.env.npm_config_strict_ssl === 'true', + force: process.env.force_no_cache === 'true', + quiet: process.env.npm_config_loglevel === 'silent' || process.env.CI +}, extractFile) + +// unzips and makes path.txt point at the correct executable +function extractFile (err, zipPath) { + if (err) return onerror(err) + extract(zipPath, { dir: path.join(__dirname, 'dist') }, function (err) { + if (err) return onerror(err) + fs.writeFile(path.join(__dirname, 'path.txt'), platformPath, function (err) { + if (err) return onerror(err) + }) + }) +} + +function onerror (err) { + throw err +} + +function getPlatformPath () { + var platform = process.env.npm_config_platform || os.platform() + + switch (platform) { + case 'darwin': + return 'Electron.app/Contents/MacOS/Electron' + case 'freebsd': + case 'linux': + return 'electron' + case 'win32': + return 'electron.exe' + default: + throw new Error('Electron builds are not available on platform: ' + platform) + } +} |