mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-10 23:39:03 +00:00
de-async-ifying stuff = tray fixed!
This commit is contained in:
parent
b13fe98d40
commit
d423bdbfd0
@ -23,7 +23,7 @@ module.exports = {
|
|||||||
'https://camo.githubusercontent.com/5c5bca9e987d986b8cc7e51066f90c6f8a84af08/68747470733a2f2f63646e2e646973636f72646170702e636f6d2f6174746163686d656e74732f3733313634373938343332333931393933332f3733313732373235393239353032333132342f494d475f323137302e6a7067',
|
'https://camo.githubusercontent.com/5c5bca9e987d986b8cc7e51066f90c6f8a84af08/68747470733a2f2f63646e2e646973636f72646170702e636f6d2f6174746163686d656e74732f3733313634373938343332333931393933332f3733313732373235393239353032333132342f494d475f323137302e6a7067',
|
||||||
options: [],
|
options: [],
|
||||||
hacks: {
|
hacks: {
|
||||||
// 'main/main.js': require('./tray.js')(defaults),
|
'main/main.js': require('./tray.js')(defaults),
|
||||||
'renderer/preload.js': function (store) {
|
'renderer/preload.js': function (store) {
|
||||||
const data = store({ name: 'dragonwocky' });
|
const data = store({ name: 'dragonwocky' });
|
||||||
console.log(data.name);
|
console.log(data.name);
|
||||||
|
@ -6,76 +6,80 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
let tray;
|
let tray;
|
||||||
const electron = require('electron'),
|
|
||||||
path = require('path'),
|
|
||||||
is_mac = process.platform === 'darwin',
|
|
||||||
is_win = process.platform === 'win32',
|
|
||||||
settings = {};
|
|
||||||
|
|
||||||
electron.app.on('ready', () => {
|
module.exports = (defaults) =>
|
||||||
tray = new electron.Tray(
|
function (store) {
|
||||||
is_win
|
const electron = require('electron'),
|
||||||
? path.resolve(__dirname, 'windows.ico')
|
path = require('path'),
|
||||||
: new electron.nativeImage.createFromPath(
|
is_mac = process.platform === 'darwin',
|
||||||
path.resolve(__dirname, 'mac+linux.png')
|
is_win = process.platform === 'win32',
|
||||||
).resize({
|
settings = store(defaults);
|
||||||
width: 16,
|
|
||||||
height: 16,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
const contextMenu = electron.Menu.buildFromTemplate([
|
electron.app.on('ready', () => {
|
||||||
{
|
tray = new electron.Tray(
|
||||||
type: 'normal',
|
is_win
|
||||||
label: 'Bug Report',
|
? path.normalize(`${__dirname}/windows.ico`)
|
||||||
},
|
: new electron.nativeImage.createFromPath(
|
||||||
{
|
path.normalize(`${__dirname}/mac+linux.png`)
|
||||||
type: 'normal',
|
).resize({
|
||||||
label: 'Feature Request',
|
width: 16,
|
||||||
},
|
height: 16,
|
||||||
{
|
})
|
||||||
type: 'separator',
|
);
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'normal',
|
|
||||||
label: 'Docs',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'normal',
|
|
||||||
label: 'Enhancements',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'separator',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Quit',
|
|
||||||
role: 'quit',
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
tray.setContextMenu(contextMenu);
|
|
||||||
tray.setToolTip('Notion');
|
|
||||||
|
|
||||||
function showWindows() {
|
const contextMenu = electron.Menu.buildFromTemplate([
|
||||||
const windows = electron.BrowserWindow.getAllWindows();
|
{
|
||||||
if (is_mac) electron.app.show();
|
type: 'normal',
|
||||||
if (settings.maximized) windows.forEach((win) => [win.maximize()]);
|
label: 'Bug Report',
|
||||||
else windows.forEach((win) => win.show());
|
},
|
||||||
electron.app.focus({ steal: true });
|
{
|
||||||
}
|
type: 'normal',
|
||||||
function hideWindows() {
|
label: 'Feature Request',
|
||||||
const windows = electron.BrowserWindow.getAllWindows();
|
},
|
||||||
windows.forEach((win) => [win.isFocused() && win.blur(), win.hide()]);
|
{
|
||||||
if (is_mac) electron.app.hide();
|
type: 'separator',
|
||||||
}
|
},
|
||||||
tray.on('click', () => {
|
{
|
||||||
const windows = electron.BrowserWindow.getAllWindows();
|
type: 'normal',
|
||||||
if (windows.some((win) => win.isVisible())) hideWindows();
|
label: 'Docs',
|
||||||
else showWindows();
|
},
|
||||||
});
|
{
|
||||||
electron.globalShortcut.register(settings.hotkey, () => {
|
type: 'normal',
|
||||||
const windows = electron.BrowserWindow.getAllWindows();
|
label: 'Enhancements',
|
||||||
if (windows.some((win) => win.isFocused() && win.isVisible()))
|
},
|
||||||
hideWindows();
|
{
|
||||||
else showWindows();
|
type: 'separator',
|
||||||
});
|
},
|
||||||
});
|
{
|
||||||
|
label: 'Quit',
|
||||||
|
role: 'quit',
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
tray.setContextMenu(contextMenu);
|
||||||
|
tray.setToolTip('Notion');
|
||||||
|
|
||||||
|
function showWindows() {
|
||||||
|
const windows = electron.BrowserWindow.getAllWindows();
|
||||||
|
if (is_mac) electron.app.show();
|
||||||
|
if (settings.maximized) windows.forEach((win) => [win.maximize()]);
|
||||||
|
else windows.forEach((win) => win.show());
|
||||||
|
electron.app.focus({ steal: true });
|
||||||
|
}
|
||||||
|
function hideWindows() {
|
||||||
|
const windows = electron.BrowserWindow.getAllWindows();
|
||||||
|
windows.forEach((win) => [win.isFocused() && win.blur(), win.hide()]);
|
||||||
|
if (is_mac) electron.app.hide();
|
||||||
|
}
|
||||||
|
tray.on('click', () => {
|
||||||
|
const windows = electron.BrowserWindow.getAllWindows();
|
||||||
|
if (windows.some((win) => win.isVisible())) hideWindows();
|
||||||
|
else showWindows();
|
||||||
|
});
|
||||||
|
electron.globalShortcut.register(settings.hotkey, () => {
|
||||||
|
const windows = electron.BrowserWindow.getAllWindows();
|
||||||
|
if (windows.some((win) => win.isFocused() && win.isVisible()))
|
||||||
|
hideWindows();
|
||||||
|
else showWindows();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"asar": "^3.0.3",
|
"asar": "^3.0.3",
|
||||||
"cac": "^6.5.12",
|
"cac": "^6.5.12",
|
||||||
"caller-path": "^3.0.0",
|
|
||||||
"fs-extra": "^9.0.1",
|
"fs-extra": "^9.0.1",
|
||||||
"readdir-enhanced": "^6.0.3"
|
"readdir-enhanced": "^6.0.3"
|
||||||
}
|
}
|
||||||
|
31
pkg/apply.js
31
pkg/apply.js
@ -24,7 +24,6 @@ const fs = require('fs-extra'),
|
|||||||
let __notion = helpers.getNotion();
|
let __notion = helpers.getNotion();
|
||||||
module.exports = async function ({ overwrite_version } = {}) {
|
module.exports = async function ({ overwrite_version } = {}) {
|
||||||
try {
|
try {
|
||||||
__notion = await __notion;
|
|
||||||
await fs.ensureDir(helpers.data_folder);
|
await fs.ensureDir(helpers.data_folder);
|
||||||
|
|
||||||
// handle pre-existing installations: app.asar present? version set in data folder? overwrite?
|
// handle pre-existing installations: app.asar present? version set in data folder? overwrite?
|
||||||
@ -57,19 +56,16 @@ module.exports = async function ({ overwrite_version } = {}) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.info(' ...unpacking app.asar');
|
console.info(' ...unpacking app.asar');
|
||||||
const asar_app = path.resolve(__notion, 'app.asar'),
|
const asar_app = path.normalize(`${__notion}/app.asar`),
|
||||||
asar_exec = path.resolve(
|
asar_exec = path.normalize(
|
||||||
__dirname,
|
`${__dirname}/../node_modules/asar/bin/asar.js`
|
||||||
'..',
|
|
||||||
'node_modules',
|
|
||||||
'asar',
|
|
||||||
'bin',
|
|
||||||
'asar.js'
|
|
||||||
);
|
);
|
||||||
await promisify(exec)(
|
await promisify(exec)(
|
||||||
`"${asar_exec}" extract "${asar_app}" "${path.resolve(__notion, 'app')}"`
|
`"${asar_exec}" extract "${asar_app}" "${path.normalize(
|
||||||
|
`${__notion}/app`
|
||||||
|
)}"`
|
||||||
);
|
);
|
||||||
fs.move(asar_app, path.resolve(__notion, 'app.asar.bak'));
|
fs.move(asar_app, path.normalize(`${__notion}/app.asar.bak`));
|
||||||
|
|
||||||
// patching launch script target of custom wrappers
|
// patching launch script target of custom wrappers
|
||||||
if (
|
if (
|
||||||
@ -98,28 +94,31 @@ module.exports = async function ({ overwrite_version } = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for await (let insertion_target of readdirIterator(
|
for await (let insertion_target of readdirIterator(
|
||||||
path.resolve(__notion, 'app'),
|
path.normalize(`${__notion}/app`),
|
||||||
{
|
{
|
||||||
deep: (stats) => stats.path.indexOf('node_modules') === -1,
|
deep: (stats) => stats.path.indexOf('node_modules') === -1,
|
||||||
filter: (stats) => stats.isFile() && stats.path.endsWith('.js'),
|
filter: (stats) => stats.isFile() && stats.path.endsWith('.js'),
|
||||||
}
|
}
|
||||||
)) {
|
)) {
|
||||||
insertion_target = path.resolve(__notion, 'app', insertion_target);
|
insertion_target = path.normalize(`${__notion}/app/${insertion_target}`);
|
||||||
fs.appendFile(
|
fs.appendFile(
|
||||||
insertion_target,
|
insertion_target,
|
||||||
`\n\n//notion-enhancer\nrequire('${helpers.realpath(
|
`\n\n//notion-enhancer\nrequire('${helpers.realpath(
|
||||||
__dirname
|
__dirname
|
||||||
)}/loader.js')();`
|
)}/loader.js')(__filename);`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// not resolved, nothing depends on it so it's just a "let it do its thing"
|
// not resolved, nothing depends on it so it's just a "let it do its thing"
|
||||||
console.info(' ...recording enhancement version.');
|
console.info(' ...recording enhancement version.');
|
||||||
fs.outputFile(
|
fs.outputFile(
|
||||||
path.resolve(__notion, 'app', 'ENHANCER_VERSION.txt'),
|
path.normalize(`${__notion}/app/ENHANCER_VERSION.txt`),
|
||||||
|
version
|
||||||
|
);
|
||||||
|
fs.outputFile(
|
||||||
|
path.normalize(`${helpers.data_folder}/version.txt`),
|
||||||
version
|
version
|
||||||
);
|
);
|
||||||
fs.outputFile(path.resolve(helpers.data_folder, 'version.txt'), version);
|
|
||||||
|
|
||||||
console.info(' ~~ success.');
|
console.info(' ~~ success.');
|
||||||
return true;
|
return true;
|
||||||
|
@ -14,13 +14,11 @@ const fs = require('fs-extra'),
|
|||||||
|
|
||||||
let __notion = helpers.getNotion();
|
let __notion = helpers.getNotion();
|
||||||
module.exports = async function () {
|
module.exports = async function () {
|
||||||
__notion = await __notion;
|
const version_path = path.normalize(`${__notion}/app/ENHANCER_VERSION.txt`),
|
||||||
|
|
||||||
const version_path = path.resolve(__notion, 'app', 'ENHANCER_VERSION.txt'),
|
|
||||||
installed_version = (await fs.pathExists(version_path))
|
installed_version = (await fs.pathExists(version_path))
|
||||||
? await fs.readFile(version_path, 'utf8')
|
? await fs.readFile(version_path, 'utf8')
|
||||||
: '?.?.?';
|
: '?.?.?';
|
||||||
if (await fs.pathExists(path.resolve(__notion, 'app.asar'))) {
|
if (await fs.pathExists(path.normalize(`${__notion}/app.asar`))) {
|
||||||
return {
|
return {
|
||||||
msg: `notion-enhancer has not been applied.`,
|
msg: `notion-enhancer has not been applied.`,
|
||||||
code: 0,
|
code: 0,
|
||||||
|
@ -25,20 +25,21 @@ 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_folder = path.resolve(
|
data_folder = path.normalize(
|
||||||
is_wsl
|
`${
|
||||||
? (() => {
|
is_wsl
|
||||||
const stdout = execSync('cmd.exe /c echo %systemdrive%%homepath%', {
|
? (() => {
|
||||||
encoding: 'utf8',
|
const stdout = execSync('cmd.exe /c echo %systemdrive%%homepath%', {
|
||||||
}),
|
encoding: 'utf8',
|
||||||
drive = stdout[0];
|
}),
|
||||||
return `/mnt/${drive.toLowerCase()}${stdout
|
drive = stdout[0];
|
||||||
.replace(/\\/g, '/')
|
return `/mnt/${drive.toLowerCase()}${stdout
|
||||||
.slice(2)
|
.replace(/\\/g, '/')
|
||||||
.trim()}`;
|
.slice(2)
|
||||||
})()
|
.trim()}`;
|
||||||
: os.homedir(),
|
})()
|
||||||
'.notion-enhancer'
|
: os.homedir()
|
||||||
|
}/.notion-enhancer`
|
||||||
);
|
);
|
||||||
|
|
||||||
// transform a wsl filepath to its relative windows filepath if necessary.
|
// transform a wsl filepath to its relative windows filepath if necessary.
|
||||||
@ -53,7 +54,7 @@ function realpath(hack_path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// gets possible system notion app filepaths.
|
// gets possible system notion app filepaths.
|
||||||
async function getNotion() {
|
function getNotion() {
|
||||||
let folder = '';
|
let folder = '';
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
@ -64,9 +65,9 @@ async function getNotion() {
|
|||||||
break;
|
break;
|
||||||
case 'linux':
|
case 'linux':
|
||||||
if (is_wsl) {
|
if (is_wsl) {
|
||||||
const { stdout } = await promisify(exec)(
|
const stdout = execSync('cmd.exe /c echo %localappdata%', {
|
||||||
'cmd.exe /c echo %localappdata%'
|
encoding: 'utf8',
|
||||||
),
|
}),
|
||||||
drive = stdout[0];
|
drive = stdout[0];
|
||||||
folder = `/mnt/${drive.toLowerCase()}${stdout
|
folder = `/mnt/${drive.toLowerCase()}${stdout
|
||||||
.replace(/\\/g, '/')
|
.replace(/\\/g, '/')
|
||||||
@ -78,7 +79,7 @@ async function getNotion() {
|
|||||||
'/opt/notion-app', // https://aur.archlinux.org/packages/notion-app/
|
'/opt/notion-app', // https://aur.archlinux.org/packages/notion-app/
|
||||||
'/opt/notion', // https://github.com/jaredallard/notion-app
|
'/opt/notion', // https://github.com/jaredallard/notion-app
|
||||||
]) {
|
]) {
|
||||||
if (await fs.pathExists(loc)) folder = loc;
|
if (fs.pathExistsSync(loc)) folder = loc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,17 +90,17 @@ async function getNotion() {
|
|||||||
);
|
);
|
||||||
// check if actual app files are present.
|
// check if actual app files are present.
|
||||||
// if app/app.asar are missing but app.asar.bak present it will be moved to app.asar
|
// if app/app.asar are missing but app.asar.bak present it will be moved to app.asar
|
||||||
const app_asar = path.resolve(folder, 'app.asar');
|
const app_asar = path.normalize(`${folder}/app.asar`);
|
||||||
if (
|
if (
|
||||||
!(
|
!(
|
||||||
(await fs.pathExists(folder)) &&
|
fs.pathExistsSync(folder) &&
|
||||||
((await fs.pathExists(app_asar)) ||
|
(fs.pathExistsSync(app_asar) ||
|
||||||
(await fs.pathExists(path.resolve(folder, 'app'))))
|
fs.pathExistsSync(path.normalize(`${folder}/app`)))
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
const asar_bak = path.resolve(folder, 'app.asar.bak');
|
const asar_bak = path.normalize(`${__notion}/app.asar.bak`);
|
||||||
if (await fs.pathExists(asar_bak)) {
|
if (fs.pathExistsSync(asar_bak)) {
|
||||||
await fs.move(asar_bak, app_asar);
|
fs.moveSync(asar_bak, app_asar);
|
||||||
} else
|
} else
|
||||||
throw new EnhancerError(
|
throw new EnhancerError(
|
||||||
'nothing found: notion installation is either corrupted or non-existent.'
|
'nothing found: notion installation is either corrupted or non-existent.'
|
||||||
|
@ -55,7 +55,7 @@ primarily used for internal handling of filepaths (e.g. for the modloader).
|
|||||||
---
|
---
|
||||||
|
|
||||||
```js
|
```js
|
||||||
async function getNotion() {
|
function getNotion() {
|
||||||
return notion_app_path;
|
return notion_app_path;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -8,19 +8,16 @@
|
|||||||
const fs = require('fs-extra'),
|
const fs = require('fs-extra'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
helpers = require('./helpers.js'),
|
helpers = require('./helpers.js'),
|
||||||
store = require('./store.js'),
|
store = require('./store.js');
|
||||||
caller = require('caller-path');
|
|
||||||
|
|
||||||
let __notion = helpers.getNotion();
|
let __notion = helpers.getNotion();
|
||||||
module.exports = async function () {
|
module.exports = function (__file) {
|
||||||
let __file = caller();
|
|
||||||
__notion = await __notion;
|
|
||||||
__file = __file
|
__file = __file
|
||||||
.slice(path.resolve(__notion, 'app').length + 1)
|
.slice(path.normalize(`${__notion}/app`).length + 1)
|
||||||
.replace(/\\/g, '/');
|
.replace(/\\/g, '/');
|
||||||
|
|
||||||
const modules = {
|
const modules = {
|
||||||
source: await fs.readdir(path.resolve(__dirname, '..', 'mods')),
|
source: fs.readdirSync(path.normalize(`${__dirname}/../mods`)),
|
||||||
invalid: [],
|
invalid: [],
|
||||||
loaded: [],
|
loaded: [],
|
||||||
};
|
};
|
||||||
@ -42,9 +39,9 @@ module.exports = async function () {
|
|||||||
);
|
);
|
||||||
if (
|
if (
|
||||||
__file === 'renderer/preload.js' &&
|
__file === 'renderer/preload.js' &&
|
||||||
(await fs.pathExists(
|
fs.pathExistsSync(
|
||||||
path.resolve(__dirname, '..', 'mods', dir, 'styles.css')
|
path.normalize(`${__dirname}/../mods/${dir}/styles.css`)
|
||||||
))
|
)
|
||||||
) {
|
) {
|
||||||
document.addEventListener('readystatechange', (event) => {
|
document.addEventListener('readystatechange', (event) => {
|
||||||
if (document.readyState !== 'complete') return false;
|
if (document.readyState !== 'complete') return false;
|
||||||
@ -66,11 +63,8 @@ module.exports = async function () {
|
|||||||
.session.fromPartition('persist:notion')
|
.session.fromPartition('persist:notion')
|
||||||
.protocol.registerFileProtocol('enhancement', (req, callback) => {
|
.protocol.registerFileProtocol('enhancement', (req, callback) => {
|
||||||
callback({
|
callback({
|
||||||
path: path.resolve(
|
path: path.normalize(
|
||||||
__dirname,
|
`${__dirname}/../mods/${req.url.slice('enhancement://'.length)}`
|
||||||
'..',
|
|
||||||
'mods',
|
|
||||||
req.url.slice('enhancement://'.length)
|
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -21,21 +21,20 @@ let __notion = helpers.getNotion();
|
|||||||
module.exports = async function ({ overwrite_asar, delete_data } = {}) {
|
module.exports = async function ({ overwrite_asar, delete_data } = {}) {
|
||||||
try {
|
try {
|
||||||
const file_operations = [];
|
const file_operations = [];
|
||||||
__notion = await __notion;
|
|
||||||
|
|
||||||
// extracted asar: modded
|
// extracted asar: modded
|
||||||
const app_folder = path.resolve(__notion, 'app');
|
const app_folder = path.normalize(`${__notion}/app`);
|
||||||
if (await fs.pathExists(app_folder)) {
|
if (await fs.pathExists(app_folder)) {
|
||||||
console.info(` ...removing folder ${app_folder}`);
|
console.info(` ...removing folder ${app_folder}`);
|
||||||
file_operations.push(fs.remove(app_folder));
|
file_operations.push(fs.remove(app_folder));
|
||||||
} else console.warn(` * ${app_folder} not found: step skipped.`);
|
} else console.warn(` * ${app_folder} not found: step skipped.`);
|
||||||
|
|
||||||
// restoring original asar
|
// restoring original asar
|
||||||
const asar_bak = path.resolve(__notion, 'app.asar.bak');
|
const asar_bak = path.normalize(`${__notion}/app.asar.bak`);
|
||||||
if (await fs.pathExists(asar_bak)) {
|
if (await fs.pathExists(asar_bak)) {
|
||||||
console.info(' ...moving asar.app.bak to app.asar');
|
console.info(' ...moving asar.app.bak to app.asar');
|
||||||
|
|
||||||
if (await fs.pathExists(path.resolve(__notion, 'app.asar'))) {
|
if (await fs.pathExists(path.normalize(`${__notion}/app.asar`))) {
|
||||||
console.warn(' * app.asar already exists!');
|
console.warn(' * app.asar already exists!');
|
||||||
if (overwrite_asar === undefined) {
|
if (overwrite_asar === undefined) {
|
||||||
do {
|
do {
|
||||||
@ -57,7 +56,7 @@ module.exports = async function ({ overwrite_asar, delete_data } = {}) {
|
|||||||
|
|
||||||
file_operations.push(
|
file_operations.push(
|
||||||
overwrite_asar || overwrite_asar === undefined
|
overwrite_asar || overwrite_asar === undefined
|
||||||
? fs.move(asar_bak, path.resolve(__notion, 'app.asar'), {
|
? fs.move(asar_bak, path.normalize(`${__notion}/app.asar`), {
|
||||||
overwrite: true,
|
overwrite: true,
|
||||||
})
|
})
|
||||||
: fs.remove(asar_bak)
|
: fs.remove(asar_bak)
|
||||||
@ -84,7 +83,7 @@ module.exports = async function ({ overwrite_asar, delete_data } = {}) {
|
|||||||
);
|
);
|
||||||
if (delete_data) {
|
if (delete_data) {
|
||||||
file_operations.push(fs.remove(helpers.data_folder));
|
file_operations.push(fs.remove(helpers.data_folder));
|
||||||
} else fs.remove(path.resolve(helpers.data_folder, 'version.txt'));
|
} else fs.remove(path.normalize(`${helpers.data_folder}/version.txt`));
|
||||||
} else console.warn(` * ${helpers.data_folder} not found: step skipped.`);
|
} else console.warn(` * ${helpers.data_folder} not found: step skipped.`);
|
||||||
|
|
||||||
await Promise.all(file_operations);
|
await Promise.all(file_operations);
|
||||||
|
@ -11,7 +11,7 @@ const path = require('path'),
|
|||||||
|
|
||||||
// a wrapper for accessing data stored in a JSON file.
|
// a wrapper for accessing data stored in a JSON file.
|
||||||
module.exports = (namespace, defaults = {}) => {
|
module.exports = (namespace, defaults = {}) => {
|
||||||
namespace = path.resolve(data_folder, namespace + '.json');
|
namespace = path.normalize(`${data_folder}/${namespace}.json`);
|
||||||
fs.ensureDirSync(data_folder);
|
fs.ensureDirSync(data_folder);
|
||||||
|
|
||||||
const getData = () => ({ ...defaults, ...getJSON(namespace) });
|
const getData = () => ({ ...defaults, ...getJSON(namespace) });
|
||||||
|
19
yarn.lock
19
yarn.lock
@ -69,25 +69,6 @@ cac@^6.5.12:
|
|||||||
resolved "https://registry.yarnpkg.com/cac/-/cac-6.6.1.tgz#3dde3f6943f45d42a56729ea3573c08b3e7b6a6d"
|
resolved "https://registry.yarnpkg.com/cac/-/cac-6.6.1.tgz#3dde3f6943f45d42a56729ea3573c08b3e7b6a6d"
|
||||||
integrity sha512-uhki4T3Ax68hw7Dufi0bATVAF8ayBSwOKUEJHjObPrUN4tlQ8Lf7oljpTje/mArLxYN0D743c2zJt4C1bVTCqg==
|
integrity sha512-uhki4T3Ax68hw7Dufi0bATVAF8ayBSwOKUEJHjObPrUN4tlQ8Lf7oljpTje/mArLxYN0D743c2zJt4C1bVTCqg==
|
||||||
|
|
||||||
caller-callsite@^4.1.0:
|
|
||||||
version "4.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/caller-callsite/-/caller-callsite-4.1.0.tgz#3e33cb1d910e7b09332d59a3503b9af7462f7295"
|
|
||||||
integrity sha512-99nnnGlJexTc41xwQTr+mWl15OI5PPczUJzM4YRE7QjkefMKCXGa5gfQjCOuVrD+1TjI/fevIDHg2nz3iYN5Ig==
|
|
||||||
dependencies:
|
|
||||||
callsites "^3.1.0"
|
|
||||||
|
|
||||||
caller-path@^3.0.0:
|
|
||||||
version "3.0.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-3.0.0.tgz#a13cbec75eea1b355e3f92dc0df4288b7eebdc5f"
|
|
||||||
integrity sha512-8nvMBmBgTmEfAXywJf27jbPZlURi5xUWLwkTXa3hZFcEZa5iRnMP4sF0p00CstWNHKBENVyYWDRSByNRdshdgQ==
|
|
||||||
dependencies:
|
|
||||||
caller-callsite "^4.1.0"
|
|
||||||
|
|
||||||
callsites@^3.1.0:
|
|
||||||
version "3.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73"
|
|
||||||
integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==
|
|
||||||
|
|
||||||
chromium-pickle-js@^0.2.0:
|
chromium-pickle-js@^0.2.0:
|
||||||
version "0.2.0"
|
version "0.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/chromium-pickle-js/-/chromium-pickle-js-0.2.0.tgz#04a106672c18b085ab774d983dfa3ea138f22205"
|
resolved "https://registry.yarnpkg.com/chromium-pickle-js/-/chromium-pickle-js-0.2.0.tgz#04a106672c18b085ab774d983dfa3ea138f22205"
|
||||||
|
Loading…
Reference in New Issue
Block a user