2019-08-20 00:09:29 +03:00
|
|
|
const
|
|
|
|
{ existsSync } = require('fs'),
|
2019-10-07 21:36:56 +03:00
|
|
|
{ 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-08-20 00:09:29 +03:00
|
|
|
function getAppDir() {
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
const appDir = getAppDir(),
|
|
|
|
tauriDir = resolve(appDir, 'src-tauri')
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
appDir,
|
|
|
|
tauriDir,
|
|
|
|
|
|
|
|
resolve: {
|
|
|
|
app: dir => join(appDir, dir),
|
|
|
|
tauri: dir => join(tauriDir, dir)
|
|
|
|
}
|
|
|
|
}
|