Skip to content
Permalink
Browse files

feat(app): New object prop for quasar.conf.js: "bin" (paths to differ…

…ent tools, like Android Studio, if they are needed)
  • Loading branch information...
rstoenescu committed Oct 9, 2019
1 parent 3d894c7 commit 2ee110d4779091fa3447b774699eab31f8a3dcbb
Showing with 30 additions and 13 deletions.
  1. +2 −2 app/lib/capacitor/index.js
  2. +2 −2 app/lib/cordova/index.js
  3. +25 −9 app/lib/helpers/open-ide.js
  4. +1 −0 app/lib/quasar-config.js
@@ -42,7 +42,7 @@ class CapacitorRunner {

await this.__runCapacitorCommand(['sync', cfg.ctx.targetName])

openIde('capacitor', cfg.ctx.targetName, true)
openIde('capacitor', cfg.bin, cfg.ctx.targetName, true)
}

async build (quasarConfig, argv) {
@@ -57,7 +57,7 @@ class CapacitorRunner {
}

if (argv.ide === true) {
openIde('capacitor', cfg.ctx.targetName)
openIde('capacitor', cfg.bin, cfg.ctx.targetName)
process.exit(0)
}

@@ -41,7 +41,7 @@ class CordovaRunner {
['prepare', cfg.ctx.targetName].concat(argv._)
)

openIde('cordova', cfg.ctx.targetName)
openIde('cordova', cfg.bin, cfg.ctx.targetName, true)
return
}

@@ -82,7 +82,7 @@ class CordovaRunner {
}

if (argv.ide) {
openIde('cordova', cfg.ctx.targetName)
openIde('cordova', cfg.bin, cfg.ctx.targetName)
process.exit(0)
}

@@ -46,22 +46,26 @@ function runMacOS (mode, target) {
}
}

function getLinuxPath () {
function getLinuxPath (bin) {
const canonicalPaths = [
'/usr/local/android-studio/bin/studio.sh',
'/opt/android-studio/bin/studio.sh'
]

if (bin.linuxAndroidStudio) {
canonicalPaths.unshift(bin.linuxAndroidStudio)
}

for (let studioPath of canonicalPaths) {
if (fs.existsSync(studioPath)) {
return studioPath
}
}
}

function runLinux (mode, target) {
function runLinux (mode, bin, target) {
if (target === 'android') {
const studioPath = getLinuxPath()
const studioPath = getLinuxPath(bin)
if (studioPath) {
const folder = mode === 'cordova'
? appPaths.resolve.cordova('platforms/android')
@@ -74,12 +78,16 @@ function runLinux (mode, target) {
return
}
}
else if (target === 'ios') {
warn(`⚠️ iOS target not supported on Linux`)
process.exit(1)
}

warn(`⚠️ Cannot determine path to IDE executable`)
process.exit(1)
}

function getWindowsPath () {
function getWindowsPath (bin) {
const studioPath = 'C:\\Program Files\\Android\\Android Studio\\bin\\studio64.exe'
if (fs.existsSync(studioPath)) {
return studioPath
@@ -98,11 +106,15 @@ function getWindowsPath () {
}
}
catch (e) {}

if (bin.windowsAndroidStudio && fs.existsSync(bin.windowsAndroidStudio)) {
return bin.windowsAndroidStudio
}
}

function runWindows (mode, target) {
function runWindows (mode, bin, target) {
if (target === 'android') {
const studioPath = getWindowsPath()
const studioPath = getWindowsPath(bin)
if (studioPath) {
const folder = mode === 'cordova'
? appPaths.resolve.cordova('platforms/android')
@@ -115,12 +127,16 @@ function runWindows (mode, target) {
return
}
}
else if (target === 'ios') {
warn(`⚠️ iOS target not supported on Windows`)
process.exit(1)
}

warn(`⚠️ Cannot determine path to IDE executable`)
process.exit(1)
}

module.exports = function (mode, target, dev) {
module.exports = function (mode, bin, target, dev) {
console.log()
console.log(` ⚠️ `)
console.log(` ⚠️ Opening ${target === 'ios' ? 'XCode' : 'Android Studio'} IDE...`)
@@ -138,9 +154,9 @@ module.exports = function (mode, target, dev) {
case 'darwin':
return runMacOS(mode, target)
case 'linux':
return runLinux(mode, target)
return runLinux(mode, bin, target)
case 'win32':
return runWindows(mode, target)
return runWindows(mode, bin, target)
default:
warn(`⚠️ Unsupported host OS for opening the IDE`)
process.exit(1)
@@ -210,6 +210,7 @@ class QuasarConfig {
},
cordova: {},
capacitor: {},
bin: {},
htmlVariables: {}
}, this.quasarConfigFunction(this.ctx))

0 comments on commit 2ee110d

Please sign in to comment.
You can’t perform that action at this time.