From ed4136121f4f4ab45bfece2aca2691601f5f39c3 Mon Sep 17 00:00:00 2001 From: xudafeng Date: Mon, 13 Jul 2015 16:34:52 +0800 Subject: [PATCH 1/2] support all platforms --- bin/gitopen | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bin/gitopen b/bin/gitopen index ca4c677..2d8c345 100755 --- a/bin/gitopen +++ b/bin/gitopen @@ -183,10 +183,13 @@ if (commander.verbose) { console.log(url); } -if (process.platform === 'win32' || process.platform === 'win64') { - child_process.execSync('start ' + url); -} else { // darwin, unix, linux. - child_process.execSync('open ' + url); +var platform = process.platform; +var shell = 'start'; + +if (platform !== 'win32') { + shell = platform === 'linux' ? 'xdg-open' : 'open'; } +child_process.execSync(shell + ' ' + url); + // vim:ft=javascript From 7a3acea746b1cd33df63e255c2ca4331286ce273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=B2=E8=80=98=E2=84=A2?= Date: Mon, 13 Jul 2015 17:44:32 +0800 Subject: [PATCH 2/2] refact(platform) --- bin/gitopen | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/bin/gitopen b/bin/gitopen index 2d8c345..a491714 100755 --- a/bin/gitopen +++ b/bin/gitopen @@ -177,17 +177,25 @@ if (!options.scheme) { //url = url.replace(/^https?/, options.protocol) var url = GitRemote(options); +var shell; if (commander.verbose) { - console.log('options:', options); - console.log(url); + console.log('Options:', options); + console.log('URL:', url); } -var platform = process.platform; -var shell = 'start'; - -if (platform !== 'win32') { - shell = platform === 'linux' ? 'xdg-open' : 'open'; +switch(process.platform){ +case 'win32': +case 'win64': + shell = 'start'; + break; +case 'unix': +case 'linux': + shell = 'xdg-open'; + break; +// case 'darwin': +default: + shell = 'open'; } child_process.execSync(shell + ' ' + url);