2019-11-18 00:30:14 +03:00
|
|
|
const { existsSync } = require('fs')
|
2019-11-16 21:51:46 +03:00
|
|
|
const { resolve, join, normalize, sep } = require('path')
|
2019-08-20 00:09:29 +03:00
|
|
|
|
2019-10-07 21:36:56 +03:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @returns {{length}|*}
|
|
|
|
*/
|
2019-11-16 21:51:46 +03:00
|
|
|
function getAppDir () {
|
2019-08-20 00:09:29 +03:00
|
|
|
let dir = process.cwd()
|
2019-10-07 21:36:56 +03:00
|
|
|
let count = 0
|
2019-08-20 00:09:29 +03:00
|
|
|
|
2019-10-07 21:36:56 +03:00
|
|
|
// only go up three folders max
|
|
|
|
while (dir.length && dir[dir.length - 1] !== sep && count <= 2) {
|
2019-08-20 00:09:29 +03:00
|
|
|
if (existsSync(join(dir, 'tauri.conf.js'))) {
|
|
|
|
return dir
|
|
|
|
}
|
2019-10-07 21:36:56 +03:00
|
|
|
count++
|
|
|
|
dir = normalize(join(dir, '..'))
|
2019-08-20 00:09:29 +03:00
|
|
|
}
|
|
|
|
|
2019-10-07 21:36:56 +03:00
|
|
|
// just return the current directory
|
|
|
|
return process.cwd()
|
2019-08-20 00:09:29 +03:00
|
|
|
}
|
|
|
|
|
2019-11-16 21:51:46 +03:00
|
|
|
const appDir = getAppDir()
|
|
|
|
const tauriDir = resolve(appDir, 'src-tauri')
|
2019-08-20 00:09:29 +03:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
appDir,
|
|
|
|
tauriDir,
|
|
|
|
|
|
|
|
resolve: {
|
2019-11-30 14:48:39 +03:00
|
|
|
app: dir => resolve(appDir, dir),
|
|
|
|
tauri: dir => resolve(tauriDir, dir)
|
2019-08-20 00:09:29 +03:00
|
|
|
}
|
|
|
|
}
|