Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop uuid package #418

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 6 additions & 8 deletions notifiers/toaster.js
Expand Up @@ -6,7 +6,7 @@ const notifier = path.resolve(__dirname, '../vendor/snoreToast/snoretoast');
const utils = require('../lib/utils');
const Balloon = require('./balloon');
const os = require('os');
const { v4: uuid } = require('uuid');
const { randomUUID: uuid } = require('crypto');

const EventEmitter = require('events').EventEmitter;
const util = require('util');
Expand Down Expand Up @@ -133,8 +133,10 @@ function notifyRaw(options, callback) {
resultBuffer = out;
options.pipeName = server.namedPipe;

const localNotifier = options.customPath || this.options.customPath ||
(notifier + '-x' + (is64Bit ? '64' : '86') + '.exe');
const localNotifier =
options.customPath ||
this.options.customPath ||
notifier + '-x' + (is64Bit ? '64' : '86') + '.exe';

options = utils.mapToWin8(options);
const argsList = utils.constructArgumentList(options, {
Expand All @@ -144,11 +146,7 @@ function notifyRaw(options, callback) {
noEscape: true
});

utils.fileCommand(
localNotifier,
argsList,
actionJackedCallback
);
utils.fileCommand(localNotifier, argsList, actionJackedCallback);
});
return this;
}
Expand Down
7 changes: 5 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Expand Up @@ -64,7 +64,6 @@
"is-wsl": "^2.2.0",
"semver": "^7.3.5",
"shellwords": "^0.1.1",
"uuid": "^8.3.2",
"which": "^2.0.2"
},
"lint-staged": {
Expand Down
28 changes: 15 additions & 13 deletions test/toaster.js
Expand Up @@ -3,8 +3,8 @@ const utils = require('../lib/utils');
const path = require('path');
const os = require('os');
const testUtils = require('./_test-utils');
jest.mock('uuid', () => {
return { v4: () => '123456789' };
jest.mock('crypto', () => {
return { randomUUID: () => '123456789' };
});

describe('WindowsToaster', function () {
Expand Down Expand Up @@ -66,7 +66,7 @@ describe('WindowsToaster', function () {
icon: 'file:///C:/node-notifier/test/fixture/coulson.jpg',
id: 1337,
sound: 'Notification.IM',
actions: ['Ok', 'Cancel'],
actions: ['Ok', 'Cancel']
});
});

Expand All @@ -80,7 +80,7 @@ describe('WindowsToaster', function () {
notifier.notify({
title: 'Heya',
message: 'foo bar',
silent: true,
silent: true
});
});

Expand All @@ -93,7 +93,7 @@ describe('WindowsToaster', function () {

notifier.notify({
title: 'Heya',
message: 'foo bar',
message: 'foo bar'
});
});

Expand All @@ -106,7 +106,7 @@ describe('WindowsToaster', function () {

notifier.notify({
message: 'Heya',
appIcon: 'file:///C:/node-notifier/test/fixture/coulson.jpg',
appIcon: 'file:///C:/node-notifier/test/fixture/coulson.jpg'
});
});

Expand Down Expand Up @@ -249,7 +249,7 @@ describe('WindowsToaster', function () {
notifier.notify({
title: 'Heya',
message: 'foo bar',
sound: 'Notification.IM',
sound: 'Notification.IM'
});
});

Expand All @@ -264,7 +264,7 @@ describe('WindowsToaster', function () {
notifier.notify({
title: 'Heya',
message: 'foo bar',
icon: 'file:///C:/node-notifier/test/fixture/coulson.jpg',
icon: 'file:///C:/node-notifier/test/fixture/coulson.jpg'
});
});

Expand Down Expand Up @@ -310,7 +310,7 @@ describe('WindowsToaster', function () {
'-s',
'Notification.IM',
'-b',
'Ok;Cancel',
'Ok;Cancel'
]);
};
const notifier = new Notify();
Expand All @@ -326,7 +326,7 @@ describe('WindowsToaster', function () {
icon: 'file:///C:/node-notifier/test/fixture/coulson.jpg',
id: 1337,
sound: 'Notification.IM',
actions: ['Ok', 'Cancel'],
actions: ['Ok', 'Cancel']
});
});

Expand All @@ -348,7 +348,7 @@ describe('WindowsToaster', function () {
id: 1337,
sound: 'Notification.IM',
customPath: '/test/customPath/snoretoast-x64.exe',
actions: ['Ok', 'Cancel'],
actions: ['Ok', 'Cancel']
});
});

Expand All @@ -358,7 +358,9 @@ describe('WindowsToaster', function () {
done();
};

const notifier = new Notify({ customPath: '/test/customPath/snoretoast-x64.exe' });
const notifier = new Notify({
customPath: '/test/customPath/snoretoast-x64.exe'
});

notifier.notify({
title: 'Heya',
Expand All @@ -369,7 +371,7 @@ describe('WindowsToaster', function () {
bar: true,
id: 1337,
sound: 'Notification.IM',
actions: ['Ok', 'Cancel'],
actions: ['Ok', 'Cancel']
});
});
});