mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-19 19:19:03 +00:00
simplify getNotionResources assuming notion-enhancer is inside node_modules
This commit is contained in:
parent
336d8bd980
commit
9af9d6320b
@ -52,39 +52,14 @@ function realpath(hack_path) {
|
|||||||
return hack_path;
|
return hack_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
// gets possible system notion app filepaths.
|
// gets system notion app filepath.
|
||||||
function getNotionResources() {
|
function getNotionResources() {
|
||||||
let folder = '';
|
// __dirname: pkg
|
||||||
switch (process.platform) {
|
// __dirname/..: notion-enhancer
|
||||||
case 'darwin':
|
// __dirname/../..: node_modules
|
||||||
folder = '/Applications/Notion.app/Contents/Resources';
|
// __dirname/../../..: app
|
||||||
break;
|
// __dirname/../../../..: resources
|
||||||
case 'win32':
|
return path.resolve(__dirname + '/../../../..');
|
||||||
folder = process.env.LOCALAPPDATA + '\\Programs\\Notion\\resources';
|
|
||||||
break;
|
|
||||||
case 'linux':
|
|
||||||
if (is_wsl) {
|
|
||||||
const stdout = execSync('cmd.exe /c echo %localappdata%', {
|
|
||||||
encoding: 'utf8',
|
|
||||||
}),
|
|
||||||
drive = stdout[0];
|
|
||||||
folder = `/mnt/${drive.toLowerCase()}${stdout
|
|
||||||
.replace(/\\/g, '/')
|
|
||||||
.slice(2)
|
|
||||||
.trim()}/Programs/Notion/resources`;
|
|
||||||
} else {
|
|
||||||
for (let loc of [
|
|
||||||
'/usr/lib/notion-desktop/resources', // https://github.com/davidbailey00/notion-deb-builder/
|
|
||||||
'/opt/notion-app', // https://aur.archlinux.org/packages/notion-app/
|
|
||||||
'/opt/notion', // https://github.com/jaredallard/notion-app
|
|
||||||
]) {
|
|
||||||
if (fs.pathExistsSync(loc)) folder = loc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!folder)
|
|
||||||
throw new EnhancerError('nothing found: platform not supported.');
|
|
||||||
return folder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// lists/fetches all available extensions + themes
|
// lists/fetches all available extensions + themes
|
||||||
|
Loading…
Reference in New Issue
Block a user