├── .gitignore ├── ISSUE_TEMPLATE ├── PULL_REQUEST_TEMPLATE ├── .npmignore ├── .travis.yml ├── issue_template.md ├── cli.js ├── index.js ├── CONTRIBUTING.md ├── test ├── index.js └── errors.js ├── appveyor.yml ├── package.json ├── LICENSE ├── install.js └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | path.txt 4 | .DS_Store 5 | npm-debug.log 6 | -------------------------------------------------------------------------------- /ISSUE_TEMPLATE: -------------------------------------------------------------------------------- 1 | This repository has been retired. 2 | 3 | Please report issues here instead: 4 | 5 | https://github.com/electron/electron/issues -------------------------------------------------------------------------------- /PULL_REQUEST_TEMPLATE: -------------------------------------------------------------------------------- 1 | This repository has been retired. 2 | 3 | Please open pull requests here instead: 4 | 5 | https://github.com/electron/electron -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | path.txt 3 | .npmignore 4 | .travis.yml 5 | appveyor.yml 6 | CONTRIBUTING.md 7 | issue_template.md 8 | test/ 9 | npm-debug.log 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | os: 2 | - linux 3 | - osx 4 | language: node_js 5 | node_js: 6 | - '0.10' 7 | - '0.12' 8 | - '4' 9 | - '5' 10 | - '6' 11 | branches: 12 | only: 13 | - master 14 | -------------------------------------------------------------------------------- /issue_template.md: -------------------------------------------------------------------------------- 1 | If you're having an issue _installing_ Electron, this is the place to report it. 2 | 3 | If you're having an issue _using_ Electron, please report it at https://github.com/electron/electron/issues 4 | 5 | * Electron version: 6 | * Operating system: 7 | -------------------------------------------------------------------------------- /cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var electron = require('./') 4 | 5 | var proc = require('child_process') 6 | 7 | var child = proc.spawn(electron, process.argv.slice(2), {stdio: 'inherit'}) 8 | child.on('close', function (code) { 9 | process.exit(code) 10 | }) 11 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs') 2 | var path = require('path') 3 | 4 | var pathFile = path.join(__dirname, 'path.txt') 5 | 6 | if (fs.existsSync(pathFile)) { 7 | module.exports = path.join(__dirname, fs.readFileSync(pathFile, 'utf-8')) 8 | } else { 9 | throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again') 10 | } 11 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | releases for this module are handled by https://github.com/johnmuhl/electron-prebuilt-updater 2 | 3 | versions published to npm should match the versions published to [github releases for electron](https://github.com/electron/electron/releases) 4 | 5 | coding style should be `standard`: 6 | 7 | [![js-standard-style](https://raw.githubusercontent.com/feross/standard/master/badge.png)](https://github.com/feross/standard) 8 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | var tape = require('tape') 2 | var electron = require('../') 3 | var path = require('path') 4 | var pathExists = require('path-exists') 5 | var getHomePath = require('home-path')() 6 | 7 | tape('has local binary', function (t) { 8 | t.ok(pathExists.sync(electron), 'electron was downloaded') 9 | t.end() 10 | }) 11 | 12 | tape('has cache folder', function (t) { 13 | t.ok(pathExists.sync(path.join(getHomePath, './.electron')), 'cache exists') 14 | t.end() 15 | }) 16 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | build: off 2 | 3 | branches: 4 | only: 5 | - master 6 | 7 | environment: 8 | matrix: 9 | - nodejs_version: "0.10" 10 | - nodejs_version: "0.12" 11 | - nodejs_version: "4" 12 | - nodejs_version: "5" 13 | - nodejs_version: "6" 14 | 15 | skip_tags: true 16 | 17 | install: 18 | - ps: Install-Product node $env:nodejs_version 19 | - npm install npm 20 | - .\node_modules\.bin\npm install 21 | 22 | test_script: 23 | - node --version 24 | - .\node_modules\.bin\npm --version 25 | - .\node_modules\.bin\npm test 26 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "electron", 3 | "version": "1.6.12", 4 | "description": "Install prebuilt electron binaries for the command-line using npm", 5 | "repository": "https://github.com/electron-userland/electron-prebuilt", 6 | "scripts": { 7 | "cache-clean": "rm -rf ~/.electron && rm -rf dist", 8 | "postinstall": "node install.js", 9 | "pretest": "npm run cache-clean && npm run postinstall", 10 | "test": "tape test/*.js && standard" 11 | }, 12 | "bin": { 13 | "electron": "cli.js" 14 | }, 15 | "main": "index.js", 16 | "types": "electron.d.ts", 17 | "dependencies": { 18 | "@types/node": "^7.0.18", 19 | "electron-download": "^3.0.1", 20 | "extract-zip": "^1.0.3" 21 | }, 22 | "devDependencies": { 23 | "home-path": "^0.1.1", 24 | "path-exists": "^2.0.0", 25 | "standard": "^5.4.1", 26 | "tape": "^3.0.1" 27 | }, 28 | "author": "Mathias Buus", 29 | "license": "MIT", 30 | "directories": { 31 | "test": "test" 32 | }, 33 | "keywords": [ 34 | "electron" 35 | ] 36 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Mathias Buus-Madsen, Max Ogden and contributors 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /install.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // maintainer note - x.y.z-ab version in package.json -> x.y.z 4 | var version = require('./package').version.replace(/-.*/, '') 5 | 6 | var fs = require('fs') 7 | var os = require('os') 8 | var path = require('path') 9 | var extract = require('extract-zip') 10 | var download = require('electron-download') 11 | 12 | var installedVersion = null 13 | try { 14 | installedVersion = fs.readFileSync(path.join(__dirname, 'dist', 'version'), 'utf-8').replace(/^v/, '') 15 | } catch (ignored) { 16 | // do nothing 17 | } 18 | 19 | var platformPath = getPlatformPath() 20 | 21 | if (installedVersion === version && fs.existsSync(path.join(__dirname, platformPath))) { 22 | process.exit(0) 23 | } 24 | 25 | // downloads if not cached 26 | download({ 27 | cache: process.env.electron_config_cache, 28 | version: version, 29 | platform: process.env.npm_config_platform, 30 | arch: process.env.npm_config_arch, 31 | strictSSL: process.env.npm_config_strict_ssl === 'true', 32 | force: process.env.force_no_cache === 'true', 33 | quiet: ['info', 'verbose', 'silly', 'http'].indexOf(process.env.npm_config_loglevel) === -1 34 | }, extractFile) 35 | 36 | // unzips and makes path.txt point at the correct executable 37 | function extractFile (err, zipPath) { 38 | if (err) return onerror(err) 39 | extract(zipPath, {dir: path.join(__dirname, 'dist')}, function (err) { 40 | if (err) return onerror(err) 41 | fs.writeFile(path.join(__dirname, 'path.txt'), platformPath, function (err) { 42 | if (err) return onerror(err) 43 | }) 44 | }) 45 | } 46 | 47 | function onerror (err) { 48 | throw err 49 | } 50 | 51 | function getPlatformPath () { 52 | var platform = process.env.npm_config_platform || os.platform() 53 | 54 | switch (platform) { 55 | case 'darwin': 56 | return 'dist/Electron.app/Contents/MacOS/Electron' 57 | case 'freebsd': 58 | case 'linux': 59 | return 'dist/electron' 60 | case 'win32': 61 | return 'dist/electron.exe' 62 | default: 63 | throw new Error('Electron builds are not available on platform: ' + platform) 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # electron-prebuilt 2 | 3 | This project has been merged into the 4 | [electron/electron](https://github.com/electron/electron/tree/master/npm) 5 | repository, and the `electron` module is now published to npm as part of the 6 | Electron release process. 7 | 8 | If you're having trouble installing or using Electron, please 9 | [file an issue on the electron/electron repo](https://github.com/electron/electron/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aopen%20install%20). 10 | 11 | ## Backstory 12 | 13 | In the early days of Electron, back when it was still called `atom-shell`, there 14 | was no module published to npm, nor was there even an Electron team at GitHub. 15 | Electron was used primarly by the [Atom](https://atom.io/) team, and it was up 16 | to early adopters to manually download compiled binary builds of Electron for 17 | use in their apps. 18 | 19 | In early 2015 [Max Ogden](https://github.com/maxogden) created 20 | [`electron-download`](https://github.com/electron-userland/electron-download) 21 | and `electron-prebuilt`, two npm modules to simplify the process of installing 22 | Electron. These tools quickly became de facto standards in the Electron 23 | community. 24 | 25 | Shortly after `electron-prebuilt` was written, 26 | [John Muhl](https://github.com/johnmuhl/) created 27 | [electron-prebuilt-updater](https://github.com/electron/electron-prebuilt-updater), 28 | a Heroku app to publish the the prebuilt module to npm automatically as new 29 | versions of Electron were published on GitHub. 30 | 31 | Fast forward to mid-2017, and GitHub now has a team working full-time on 32 | Electron. We are working towards a more regular release cadence, 33 | and are incrementally documenting and [improving our release process](https://github.com/electron/electron/blob/master/docs/development/releasing.md). 34 | As we've added support for things like 35 | [TypeScript definitions](https://electron.atom.io/blog/2017/06/01/typescript), 36 | it's been challenging to work these additions into the `electron` -> `electron-prebuilt-updater` -> `electron-prebuilt` release flow. 37 | 38 | To reduce the number of moving parts in the release process, we imported 39 | the `electron-prebuilt` codebase into [`electron`](https://github.com/electron/electron/tree/master/npm) itself, and have 40 | [preserved the git history](https://github.com/electron/electron/pull/10172) 41 | to acknowledge the contributions of the 32 open-source community members who 42 | have helped improve `electron-prebuilt` over the years. -------------------------------------------------------------------------------- /test/errors.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs') 2 | var tape = require('tape') 3 | var path = require('path') 4 | var childProcess = require('child_process') 5 | 6 | tape('install fails for unsupported platforms', function (t) { 7 | install({npm_config_platform: 'android'}, function (code, stderr) { 8 | t.notEqual(stderr.indexOf('Electron builds are not available on platform: android'), -1, 'has error message') 9 | t.notEqual(code, 0, 'exited with error') 10 | t.end() 11 | }) 12 | }) 13 | 14 | tape('install fails for unsupported architectures', function (t) { 15 | install({ 16 | npm_config_arch: 'midcentury', 17 | npm_config_platform: 'win32', 18 | HOME: process.env.HOME, 19 | USERPROFILE: process.env.USERPROFILE 20 | }, function (code, stderr) { 21 | t.notEqual(stderr.indexOf('Failed to find Electron'), -1, 'has error message') 22 | t.notEqual(stderr.indexOf('win32-midcentury'), -1, 'has error message') 23 | t.notEqual(code, 0, 'exited with error') 24 | t.end() 25 | }) 26 | }) 27 | 28 | tape('require fails for corrupted installs', function (t) { 29 | cli(function (code, stderr) { 30 | t.notEqual(stderr.indexOf('Electron failed to install correctly'), -1, 'has error message') 31 | t.notEqual(code, 0, 'exited with error') 32 | t.end() 33 | }) 34 | }) 35 | 36 | function install (env, callback) { 37 | var restoreFile = removeFile(path.join(__dirname, '..', 'dist', 'version')) 38 | 39 | var installPath = path.join(__dirname, '..', 'install.js') 40 | var installProcess = childProcess.fork(installPath, { 41 | silent: true, 42 | env: env 43 | }) 44 | 45 | var stderr = '' 46 | installProcess.stderr.on('data', function (data) { 47 | stderr += data 48 | }) 49 | 50 | installProcess.on('close', function (code) { 51 | restoreFile() 52 | callback(code, stderr) 53 | }) 54 | } 55 | 56 | function cli (callback) { 57 | var restoreFile = removeFile(path.join(__dirname, '..', 'path.txt')) 58 | 59 | var cliPath = path.join(__dirname, '..', 'cli.js') 60 | var cliProcess = childProcess.fork(cliPath, { 61 | silent: true 62 | }) 63 | 64 | var stderr = '' 65 | cliProcess.stderr.on('data', function (data) { 66 | stderr += data 67 | }) 68 | 69 | cliProcess.on('close', function (code) { 70 | restoreFile() 71 | callback(code, stderr) 72 | }) 73 | } 74 | 75 | function removeFile (filePath) { 76 | var contents = null 77 | if (fs.existsSync(filePath)) { 78 | contents = fs.readFileSync(filePath) 79 | fs.unlinkSync(filePath) 80 | } 81 | return function restoreFile () { 82 | if (contents != null) { 83 | fs.writeFileSync(filePath, contents) 84 | } 85 | } 86 | } 87 | --------------------------------------------------------------------------------