Socket
Socket
Sign inDemoInstall

webpack-build-notifier

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-build-notifier - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

dist/icons/compile.png

9

CHANGELOG.md
# Changelog
#### 1.1.0
###### _August 10, 2019_
- Added two new config options: onCompileStart, onComplete.
#### 1.0.3
###### _June_ 4, 2019_
###### _June 4, 2019_

@@ -9,3 +14,3 @@ - Updated dependencies to latest versions to fix high-severity js-yaml vulnerability.

#### 1.0.2
###### _May_ 3, 2019_
###### _May 3, 2019_

@@ -12,0 +17,0 @@ - Corrected *sound TS types.

import { Plugin } from 'webpack';
import NotificationCenter from 'node-notifier/notifiers/notificationcenter';
import webpack = require("webpack");

@@ -18,2 +19,10 @@ export = WebpackBuildNotifierPlugin;

};
/**
* String to represent valid compilation results.
*/
enum CompilationStatus {
SUCCESS = 'success',
WARNING = 'warning',
ERROR = 'error',
}

@@ -55,2 +64,14 @@ type Config = {

/**
* A function which is invoked when compilation starts. Optional. The function is passed one parameter:
* 1. {webpack.compilation.Compilation} compilation - The webpack Compilation instance.
* Note that `suppressCompileStart` must be `false`.
*/
onCompileStart?: (compilation: webpack.compilation.Compilation) => void;
/**
* A function which is invoked when compilation completes. Optional. The function is passed two parameters:
* 1. {webpack.compilation.Compilation} compilation - The webpack Compilation instance.
* 2. {CompilationStatus} status - one of 'success', 'warning', or 'error'
*/
onComplete?: (compilation: webpack.compilation.Compilation, status: CompilationStatus) => void;
/**
* Defines when success notifications are shown. Can be one of the following values:

@@ -98,3 +119,2 @@ *

/**
* @cfg {Function} onClick
* A function called when clicking on a warning or error notification. By default, it activates the Terminal application.

@@ -101,0 +121,0 @@ * The function is passed two parameters:

@@ -39,3 +39,3 @@ /**

appName = 'Snore.DesktopToasts';
} catch(e) {
} catch (e) {
console.error("An error occurred while attempting to install the SnoreToast AppID!", e);

@@ -46,3 +46,3 @@ }

var WebpackBuildNotifierPlugin = function(cfg) {
var WebpackBuildNotifierPlugin = function (cfg) {
cfg = cfg || {};

@@ -106,6 +106,6 @@

this.suppressWarning = cfg.suppressWarning || false;
/**
* @cfg {Boolean} [suppressWarning=true]
* True to suppress the compilation started notifications (default), otherwise false.
*/
/**
* @cfg {Boolean} [suppressCompileStart=true]
* True to suppress the compilation started notifications (default), otherwise false.
*/
this.suppressCompileStart = cfg.suppressCompileStart !== false;

@@ -134,2 +134,16 @@ /**

/**
* @cfg {Function} [onCompileStart=undefined]
* A function which is invoked when compilation starts. Optional. The function is passed one parameter:
* 1) {webpack.compilation.Compilation} compilation - The webpack Compilation instance.
* Note that `suppressCompileStart` must be `false`.
*/
this.onCompileStart = cfg.onCompileStart;
/**
* @cfg {Function} [onComplete=undefined]
* A function which is invoked when compilation completes. Optional. The function is passed two parameters:
* 1) {webpack.compilation.Compilation} compilation - The webpack Compilation instance.
* 2) {CompilationStatus} status - one of 'success', 'warning', or 'error'
*/
this.onComplete = cfg.onComplete;
/**
* @cfg {String} [compileIcon='./icons/compile.png']

@@ -143,3 +157,3 @@ * The absolute path to the icon to be displayed for compilation started notifications.

*/
this.onClick = cfg.onClick || function(notifierObject, options) { this.activateTerminalWindow(); };
this.onClick = cfg.onClick || function (notifierObject, options) { this.activateTerminalWindow(); };
/**

@@ -163,3 +177,3 @@ * @cfg {Function} onTimeout

*/
this.messageFormatter = function(error, filepath) {
this.messageFormatter = function (error, filepath) {
var message = (cfg.messageFormatter || this.defaultMessageFormatter)(error, filepath);

@@ -194,7 +208,7 @@ if (typeof message === "string") {

WebpackBuildNotifierPlugin.prototype.defaultMessageFormatter = function(error, filepath) {
WebpackBuildNotifierPlugin.prototype.defaultMessageFormatter = function (error, filepath) {
return filepath + os.EOL + (error.message ? error.message.replace(error.module ? error.module.resource : '', '') : '');
};
WebpackBuildNotifierPlugin.prototype.activateTerminalWindow = function() {
WebpackBuildNotifierPlugin.prototype.activateTerminalWindow = function () {
if (os.platform() === 'darwin') {

@@ -206,3 +220,3 @@ // TODO: is there a way to translate $TERM_PROGRAM into the application name

'[[ "$TERM" == "vscode" ]] && TERM="Visual Studio Code"; ' +
'osascript -e "tell application \\"$TERM\\" to activate"');
'osascript -e "tell application \\"$TERM\\" to activate"');
} else if (os.platform() === 'win32') {

@@ -213,3 +227,3 @@ // TODO: Windows platform

WebpackBuildNotifierPlugin.prototype.onCompilationWatchRun = function(compilation, callback) {
WebpackBuildNotifierPlugin.prototype.onCompilationWatchRun = function (compilation, callback) {
notifier.notify({

@@ -223,6 +237,9 @@ appName: appName,

});
if (this.onCompileStart) {
this.onCompileStart(compilation);
}
callback();
};
WebpackBuildNotifierPlugin.prototype.onCompilationDone = function(results) {
WebpackBuildNotifierPlugin.prototype.onCompilationDone = function (results) {
var notify,

@@ -232,3 +249,5 @@ title = this.title + ' - ',

icon = this.successIcon,
sound = this.successSound;
sound = this.successSound,
onComplete = this.onComplete,
compilationStatus = 'success';

@@ -238,2 +257,3 @@ if (results.hasErrors()) {

notify = true;
compilationStatus = 'error';
title += 'Error';

@@ -247,2 +267,3 @@ msg = error ? this.messageFormatter(error, error.module && error.module.rawRequest ? error.module.rawRequest : '') : 'Unknown';

notify = true;
compilationStatus = 'warning';
title += 'Warning';

@@ -275,2 +296,5 @@ msg = warning ? this.messageFormatter(warning, warning.module && warning.module.rawRequest ? warning.module.rawRequest : '') : 'Unknown';

);
if (onComplete) {
onComplete(results.compilation, compilationStatus);
}
}

@@ -285,3 +309,3 @@

WebpackBuildNotifierPlugin.prototype.apply = function(compiler) {
WebpackBuildNotifierPlugin.prototype.apply = function (compiler) {
if (compiler.hooks && compiler.hooks.watchRun && compiler.hooks.done) {

@@ -288,0 +312,0 @@ // for webpack >= 4

{
"name": "webpack-build-notifier",
"version": "1.0.3",
"version": "1.1.0",
"description": "A Webpack plugin that generates OS notifications for build steps using node-notifier.",

@@ -45,2 +45,2 @@ "main": "index.js",

}
}
}

@@ -58,2 +58,12 @@ # webpack-build-notifier

#### onCompileStart
A function which is invoked when compilation starts. Optional. The function is passed one parameter:
* {webpack.compilation.Compilation} compilation - The webpack Compilation instance.
Note that `suppressCompileStart` must be `false`.
#### onComplete
A function which is invoked when compilation completes. Optional. The function is passed two parameters:
* {webpack.compilation.Compilation} compilation - The webpack Compilation instance.
* {CompilationStatus} status - one of 'success', 'warning', or 'error'
#### suppressSuccess

@@ -60,0 +70,0 @@ Defines when success notifications are shown. Can be one of the following values:

@@ -38,2 +38,4 @@ import webpack from "webpack";

expect(instanceWithTitle.compilationSound).toBe("Submarine");
expect(instanceWithTitle.onCompileStart).toEqual(undefined);
expect(instanceWithTitle.onComplete).toEqual(undefined);
expect(instanceWithTitle.suppressSuccess).toBe(false);

@@ -40,0 +42,0 @@ expect(instanceWithTitle.suppressWarning).toBe(false);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc