electron/npm/install.js

34 lines
1 KiB
JavaScript
Raw Normal View History

2014-10-20 04:17:38 +00:00
#!/usr/bin/env node
var os = require('os')
var path = require('path')
var nugget = require('nugget')
var extract = require('extract-zip')
2014-10-20 04:56:49 +00:00
var fs = require('fs')
2014-10-20 04:17:38 +00:00
2014-10-20 04:56:49 +00:00
var platform = os.platform()
var arch = os.arch()
2014-10-20 04:17:38 +00:00
var version = '0.18.0'
2014-10-20 04:56:49 +00:00
var name = 'atom-shell-v'+version+'-'+platform+'-'+arch+'.zip'
var url = 'https://github.com/atom/atom-shell/releases/download/v'+version+'/atom-shell-v'+version+'-'+platform+'-'+arch+'.zip'
2014-10-20 04:17:38 +00:00
var onerror = function(err) {
throw err
}
2014-10-20 04:56:49 +00:00
var paths = {
darwin: path.join(__dirname, './dist/Atom.app/Contents/MacOS/Atom'),
linux: path.join(__dirname, './dist/atom'),
win32: path.join(__dirname, './dist/atom.exe')
}
if (!paths[platform]) throw new Error('Unknown platform: '+platform)
2014-10-21 05:42:55 +00:00
nugget(url, {target:name, dir:__dirname, resume:true, verbose:true}, function(err) {
2014-10-20 04:17:38 +00:00
if (err) return onerror(err)
2014-10-20 05:38:15 +00:00
fs.writeFileSync(path.join(__dirname, 'run.bat'), '"'+paths[platform]+'"')
2014-10-20 04:56:49 +00:00
extract(path.join(__dirname, name), {dir:path.join(__dirname, 'dist')}, function(err) {
2014-10-20 04:17:38 +00:00
if (err) return onerror(err)
})
})