Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions notifiers/toaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function getPipeName() {
return `${PIPE_PATH_PREFIX}${PIPE_NAME}-${uuid()}`;
}

WindowsToaster.prototype.notify = async function(options, callback) {
WindowsToaster.prototype.notify = function(options, callback) {
options = utils.clone(options || {});
callback = callback || noop;
var is64Bit = os.arch() === 'x64';
Expand Down Expand Up @@ -122,22 +122,24 @@ WindowsToaster.prototype.notify = async function(options, callback) {
}

// Add pipeName option, to get the output
resultBuffer = await utils.createNamedPipe(namedPipe);
options.pipeName = namedPipe;

options = utils.mapToWin8(options);
var argsList = utils.constructArgumentList(options, {
explicitTrue: true,
wrapper: '',
keepNewlines: true,
noEscape: true
utils.createNamedPipe(namedPipe).then(out => {
resultBuffer = out;
options.pipeName = namedPipe;

options = utils.mapToWin8(options);
var argsList = utils.constructArgumentList(options, {
explicitTrue: true,
wrapper: '',
keepNewlines: true,
noEscape: true
});

var notifierWithArch = notifier + '-x' + (is64Bit ? '64' : '86') + '.exe';
utils.fileCommand(
this.options.customPath || notifierWithArch,
argsList,
actionJackedCallback
);
});

var notifierWithArch = notifier + '-x' + (is64Bit ? '64' : '86') + '.exe';
utils.fileCommand(
this.options.customPath || notifierWithArch,
argsList,
actionJackedCallback
);
return this;
};
6 changes: 3 additions & 3 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ describe('constructors', function() {
expect(notifier.notify({ title: 'My notification' }, cb)).toBeTruthy();
});

it('should throw error when second parameter is not a function', async () => {
it('should throw error when second parameter is not a function', function() {
var wrongParamOne = 200;
var wrongParamTwo = 'meaningless string';
var data = { title: 'My notification' };

var base = notifier.notify.bind(notifier, data);
await expect(base.bind(notifier, wrongParamOne)()).rejects.toThrowError(
expect(base.bind(notifier, wrongParamOne)).toThrowError(
/^The second argument/
);
await expect(base.bind(notifier, wrongParamTwo)()).rejects.toThrowError(
expect(base.bind(notifier, wrongParamTwo)).toThrowError(
/^The second argument/
);
});
Expand Down