2019-08-20 00:09:29 +03:00
|
|
|
const
|
2019-11-16 21:51:46 +03:00
|
|
|
{ existsSync } = require('fs')
|
|
|
|
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
|
|
|
|
console.log(dir)
|
|
|
|
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: {
|
|
|
|
app: dir => join(appDir, dir),
|
|
|
|
tauri: dir => join(tauriDir, dir)
|
|
|
|
}
|
|
|
|
}
|