From c1dc3e09a84ad1d9bf9640172c23d6fc72d90e04 Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Mon, 20 Oct 2014 13:56:49 +0900 Subject: [PATCH] better cross platform support --- npm/.gitignore | 5 ++--- npm/darwin.sh | 2 -- npm/index.js | 3 +++ npm/install.js | 18 +++++++++++++++--- npm/package.json | 4 ++-- 5 files changed, 22 insertions(+), 10 deletions(-) delete mode 100755 npm/darwin.sh create mode 100644 npm/index.js diff --git a/npm/.gitignore b/npm/.gitignore index fdd90df813f3..fabe685fd30d 100644 --- a/npm/.gitignore +++ b/npm/.gitignore @@ -1,5 +1,4 @@ node_modules *.zip -darwin/ -win32/ -linux/ \ No newline at end of file +dist +run.bat diff --git a/npm/darwin.sh b/npm/darwin.sh deleted file mode 100755 index 7c88674c0266..000000000000 --- a/npm/darwin.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./darwin/Atom.app/Contents/MacOS/Atom \ No newline at end of file diff --git a/npm/index.js b/npm/index.js new file mode 100644 index 000000000000..48b753f33b7c --- /dev/null +++ b/npm/index.js @@ -0,0 +1,3 @@ +var fs = require('fs') +var path = require('path') +module.exports = fs.readFileSync(path.join(__dirname, 'run.bat'), 'utf-8') \ No newline at end of file diff --git a/npm/install.js b/npm/install.js index 99a18947b932..f021c2f67763 100755 --- a/npm/install.js +++ b/npm/install.js @@ -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) }) }) diff --git a/npm/package.json b/npm/package.json index efd247d89945..563d4fe78015 100644 --- a/npm/package.json +++ b/npm/package.json @@ -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"