FIX: make notifications work when using in wsl

This commit is contained in:
Peter 2021-04-23 23:50:18 +08:00
parent 55d8b738a0
commit 8d32117d0e
2 changed files with 62 additions and 55 deletions

View File

@ -51,3 +51,4 @@ You can also view the differences (which includes data not in the table) in JSON
| 2021-01-08 | 1.0.0 | Initial release. |
| 2021-02-07 | 1.0.1 | Fix bug with diff where undefined cells would cause an error. |
| 2021-02-16 | 1.0.2 | Added temp/placeholder icon to fix notifications. Remember to add your own icon (not including originals to prevent trademark infringement) |
| 2021-04-23 | 1.0.3 | Fixed notifications on WSL due to unix-style paths not working as an argument on Windows with node-notifier |

View File

@ -3,6 +3,7 @@ const clc = require('cli-color');
const notifier = require('node-notifier');
const Diff = require('diff');
const path = require('path');
const isWsl = require('is-wsl');
const arguments = require('./tools/process-args').arguments;
const cli_elem = require('./tools/cli-elements'); //Idk js package structure/conventions...
@ -50,6 +51,11 @@ const ARCHIVE = arguments.archive;
var notified_1h = [];
var notifying_1h = [];
var ICON_PATH = path.join(__dirname, 'spacex.ico');
if (isWsl && ICON_PATH.startsWith("/mnt/",0)) {
ICON_PATH = ICON_PATH.substr(5).replace("/",":/");
}
function selectData(arr) {
const LUNCHPADS_RESP = arr[0];
const LUNCHES_RESP = arr[1];
@ -293,7 +299,7 @@ async function main() {
notifier.notify({
title: STRING.H_WARNING,
message: notifying_1h.join(' │ '),
icon: path.join(__dirname, 'spacex.ico'),
icon: ICON_PATH,
appID: STRING.APPID
});
notifying_1h = [];
@ -373,7 +379,7 @@ async function main() {
notifier.notify({
title: STRING.NEW_DATA,
message: 'Press d to see table diff. Press j to see JSON diff.',
icon: path.join(__dirname, 'spacex.ico'),
icon: ICON_PATH,
appID: STRING.APPID
});
net_tools.writeFile(path_prev_launches, JSON.stringify(curr_launches));