remove unused helpers

This commit is contained in:
David Bailey 2020-12-07 20:34:43 +00:00
parent 9af9d6320b
commit 9bc15847c4
3 changed files with 21 additions and 65 deletions

View File

@ -10,7 +10,7 @@ const fs = require('fs-extra'),
path = require('path'),
{ readdirIterator } = require('readdir-enhanced'),
{ extractAll } = require('asar'),
{ readline, realpath, getNotionResources } = require('./helpers.js'),
{ readline, getNotionResources } = require('./helpers.js'),
{ version } = require('../package.json');
// === title ===

View File

@ -8,8 +8,7 @@
const os = require('os'),
path = require('path'),
fs = require('fs-extra'),
{ execSync } = require('child_process');
fs = require('fs-extra');
// used to differentiate between "enhancer failed" and "code broken" errors.
class EnhancerError extends Error {
@ -23,9 +22,10 @@ class EnhancerError extends Error {
// used to modify windows notion app.
const is_wsl =
process.platform === 'linux' &&
os.release().toLowerCase().includes('microsoft'),
os.release().toLowerCase().includes('microsoft');
// ~/.notion-enhancer absolute path.
__data = path.resolve(
const __data = path.resolve(
`${
is_wsl
? (() => {
@ -42,16 +42,6 @@ const is_wsl =
}/.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.
function getNotionResources() {
// __dirname: pkg
@ -159,9 +149,7 @@ function createElement(html) {
module.exports = {
EnhancerError,
is_wsl,
__data,
realpath,
getNotionResources,
getEnhancements,
getJSON,

View File

@ -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
const __data;
```
@ -36,24 +26,6 @@ const __data;
use `helpers.__data` to get the absolute path of the directory configuration
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
@ -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).
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