mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-19 19:19:03 +00:00
remove unused helpers
This commit is contained in:
parent
9af9d6320b
commit
9bc15847c4
@ -10,7 +10,7 @@ const fs = require('fs-extra'),
|
|||||||
path = require('path'),
|
path = require('path'),
|
||||||
{ readdirIterator } = require('readdir-enhanced'),
|
{ readdirIterator } = require('readdir-enhanced'),
|
||||||
{ extractAll } = require('asar'),
|
{ extractAll } = require('asar'),
|
||||||
{ readline, realpath, getNotionResources } = require('./helpers.js'),
|
{ readline, getNotionResources } = require('./helpers.js'),
|
||||||
{ version } = require('../package.json');
|
{ version } = require('../package.json');
|
||||||
|
|
||||||
// === title ===
|
// === title ===
|
||||||
|
@ -8,8 +8,7 @@
|
|||||||
|
|
||||||
const os = require('os'),
|
const os = require('os'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
fs = require('fs-extra'),
|
fs = require('fs-extra');
|
||||||
{ execSync } = require('child_process');
|
|
||||||
|
|
||||||
// used to differentiate between "enhancer failed" and "code broken" errors.
|
// used to differentiate between "enhancer failed" and "code broken" errors.
|
||||||
class EnhancerError extends Error {
|
class EnhancerError extends Error {
|
||||||
@ -23,9 +22,10 @@ class EnhancerError extends Error {
|
|||||||
// used to modify windows notion app.
|
// used to modify windows notion app.
|
||||||
const is_wsl =
|
const is_wsl =
|
||||||
process.platform === 'linux' &&
|
process.platform === 'linux' &&
|
||||||
os.release().toLowerCase().includes('microsoft'),
|
os.release().toLowerCase().includes('microsoft');
|
||||||
|
|
||||||
// ~/.notion-enhancer absolute path.
|
// ~/.notion-enhancer absolute path.
|
||||||
__data = path.resolve(
|
const __data = path.resolve(
|
||||||
`${
|
`${
|
||||||
is_wsl
|
is_wsl
|
||||||
? (() => {
|
? (() => {
|
||||||
@ -42,16 +42,6 @@ const is_wsl =
|
|||||||
}/.notion-enhancer`
|
}/.notion-enhancer`
|
||||||
);
|
);
|
||||||
|
|
||||||
// transform a wsl filepath to its relative windows filepath if necessary.
|
|
||||||
function realpath(hack_path) {
|
|
||||||
if (!is_wsl) return hack_path.replace(/\\/g, '/');
|
|
||||||
hack_path = fs.realpathSync(hack_path);
|
|
||||||
if (hack_path.startsWith('/mnt/')) {
|
|
||||||
hack_path = `${hack_path[5].toUpperCase()}:${hack_path.slice(6)}`;
|
|
||||||
} else hack_path = `//wsl$/${process.env.WSL_DISTRO_NAME}${hack_path}`;
|
|
||||||
return hack_path;
|
|
||||||
}
|
|
||||||
|
|
||||||
// gets system notion app filepath.
|
// gets system notion app filepath.
|
||||||
function getNotionResources() {
|
function getNotionResources() {
|
||||||
// __dirname: pkg
|
// __dirname: pkg
|
||||||
@ -159,9 +149,7 @@ function createElement(html) {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
EnhancerError,
|
EnhancerError,
|
||||||
is_wsl,
|
|
||||||
__data,
|
__data,
|
||||||
realpath,
|
|
||||||
getNotionResources,
|
getNotionResources,
|
||||||
getEnhancements,
|
getEnhancements,
|
||||||
getJSON,
|
getJSON,
|
||||||
|
@ -19,16 +19,6 @@ but is not caused by faulty programming: e.g. if a file that is known to exist c
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
```js
|
|
||||||
const is_wsl;
|
|
||||||
```
|
|
||||||
|
|
||||||
use `helpers.is_wsl` to check if the enhancer was run from the windows subsystem for linux.
|
|
||||||
|
|
||||||
primarily used for internal handling of filepaths (e.g. in the `helpers.realpath` function).
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const __data;
|
const __data;
|
||||||
```
|
```
|
||||||
@ -36,24 +26,6 @@ const __data;
|
|||||||
use `helpers.__data` to get the absolute path of the directory configuration
|
use `helpers.__data` to get the absolute path of the directory configuration
|
||||||
data is saved to by the enhancer.
|
data is saved to by the enhancer.
|
||||||
|
|
||||||
if used immediately after being accessed, it should always work. however, if fetching its value during enhancement
|
|
||||||
and then inserting it into something that will not be executed until the app is opened, it must be put through
|
|
||||||
`helpers.realpath` before insertion.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
```js
|
|
||||||
function realpath(hack_path) {
|
|
||||||
return runtime_path;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
use `helpers.realpath(hack_path)` to transform a path valid at enhancement time into one valid when the app is opened.
|
|
||||||
this is particularly useful for wsl compatibility, so every filepath that is fetched during enhancement
|
|
||||||
and then inserted into something that will not be executed until the app is opened should be put through this.
|
|
||||||
|
|
||||||
primarily used for internal handling of filepaths (e.g. for the modloader).
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
```js
|
```js
|
||||||
@ -66,10 +38,6 @@ use `helpers.getNotionResources()` to get the absolute path of the notion app pa
|
|||||||
|
|
||||||
primarily used for internal modding of the app (e.g. to apply the modloader and patch launch scripts).
|
primarily used for internal modding of the app (e.g. to apply the modloader and patch launch scripts).
|
||||||
|
|
||||||
if used immediately after being accessed, it should always work. however, if fetching its value during enhancement
|
|
||||||
and then inserting it into something that will not be executed until the app is opened, it must be put through
|
|
||||||
`helpers.realpath` before insertion.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
Loading…
Reference in New Issue
Block a user