better cross platform support
This commit is contained in:
parent
359504809b
commit
c1dc3e09a8
5 changed files with 22 additions and 10 deletions
5
npm/.gitignore
vendored
5
npm/.gitignore
vendored
|
@ -1,5 +1,4 @@
|
|||
node_modules
|
||||
*.zip
|
||||
darwin/
|
||||
win32/
|
||||
linux/
|
||||
dist
|
||||
run.bat
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
#!/bin/bash
|
||||
./darwin/Atom.app/Contents/MacOS/Atom
|
3
npm/index.js
Normal file
3
npm/index.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
module.exports = fs.readFileSync(path.join(__dirname, 'run.bat'), 'utf-8')
|
|
@ -4,18 +4,30 @@ var os = require('os')
|
|||
var path = require('path')
|
||||
var nugget = require('nugget')
|
||||
var extract = require('extract-zip')
|
||||
var fs = require('fs')
|
||||
|
||||
var platform = os.platform()
|
||||
var arch = os.arch()
|
||||
var version = '0.18.0'
|
||||
var name = version+'-atom-shell.zip'
|
||||
var url = 'https://github.com/atom/atom-shell/releases/download/v'+version+'/atom-shell-v'+version+'-'+os.platform()+'-'+os.arch()+'.zip'
|
||||
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'
|
||||
|
||||
var onerror = function(err) {
|
||||
throw err
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
nugget(url, {target:name, dir:__dirname, resume:true}, function(err) {
|
||||
if (err) return onerror(err)
|
||||
extract(path.join(__dirname, name), {dir:path.join(__dirname, os.platform())}, function(err) {
|
||||
fs.writeFileSync(path.join(__dirname, 'run.bat'), paths[platform])
|
||||
extract(path.join(__dirname, name), {dir:path.join(__dirname, 'dist')}, function(err) {
|
||||
if (err) return onerror(err)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
"install": "./install.js"
|
||||
},
|
||||
"bin": {
|
||||
"atom-shell": "./darwin.sh"
|
||||
"atom-shell": "run.bat"
|
||||
},
|
||||
"main": "install.js",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"extract-zip": "^1.0.3",
|
||||
"nugget": "^1.1.2"
|
||||
|
|
Loading…
Reference in a new issue