Skip to content

Commit

Permalink
Fixed #51.
Browse files Browse the repository at this point in the history
  • Loading branch information
RoccoC committed May 24, 2020
1 parent c10e84a commit ba2e03a
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 19 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

#### 2.0.1
###### _May 23, 2020_

- Fixed bug where setting *sound* to *false* had no effect ([#51](/../../issues/51)).

#### 2.0.0
###### _October 15, 2019_

Expand Down
24 changes: 12 additions & 12 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webpack-build-notifier",
"version": "2.0.0",
"version": "2.0.1",
"description": "A Webpack plugin that generates OS notifications for build steps using node-notifier.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -50,7 +50,7 @@
"ts-jest": "^24.1.0",
"tslint": "^5.20.0",
"tslint-config-airbnb": "^5.11.2",
"typescript": "^3.6.4",
"typescript": "^3.9.3",
"webpack": "^4.41.2"
}
}
}
15 changes: 11 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ export default class WebpackBuildNotifierPlugin {
private title: string = 'Webpack Build';
private logo?: string;
private sound: string = 'Submarine';
private successSound: string = this.sound;
private warningSound: string = this.sound;
private failureSound: string = this.sound;
private compilationSound: string = this.sound;
private successSound: string;
private warningSound: string;
private failureSound: string;
private compilationSound: string;
private suppressSuccess: boolean | 'always' | 'initial' = false;
private suppressWarning: boolean = false;
private suppressCompileStart: boolean = true;
Expand All @@ -47,6 +47,13 @@ export default class WebpackBuildNotifierPlugin {
constructor(cfg?: Config) {
Object.assign(this, cfg);

if (this.sound) {
this.successSound = this.successSound ?? this.sound;
this.warningSound = this.warningSound ?? this.sound;
this.failureSound = this.failureSound ?? this.sound;
this.compilationSound = this.compilationSound ?? this.sound;
}

this.registerSnoreToast();

notifier.on('click', this.onClick);
Expand Down
17 changes: 17 additions & 0 deletions tests/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,23 @@ describe('Test Webpack build', () => {
});
});

it('Should show a success notification with no sound', (done) => {
const onComplete = jest.fn();
expect.assertions(2);
webpack(getWebpackConfig({ onComplete, sound: false }), (err, stats) => {
expect(notifier.notify).toHaveBeenCalledWith({
appName: platformName === 'Windows' ? 'Snore.DesktopToasts' : undefined,
contentImage: undefined,
icon: require.resolve('../src/icons/success.png'),
message: 'Build successful!',
title: 'Build Notification Test - Success',
wait: false,
});
expect(onComplete).toHaveBeenCalledWith(expect.any(Object), CompilationStatus.SUCCESS);
done();
});
});

it('Should show a success notification with duration', (done) => {
expect.assertions(1);
webpack(getWebpackConfig({ showDuration: true }), (err, stats) => {
Expand Down

0 comments on commit ba2e03a

Please sign in to comment.