@wulechuan/javascript-gulp-plugin-error-printer
v1.2.3
Published
[PROJECT DEPRECATED] Please refer to "@wulechuan/printer-for-errors-of-gulp-plugins".
Downloads
9
Maintainers
Readme
Printer of Errors of Glup Plugins [PROJECT DEPRECATED]
NPM Page
@wulechuan/javascript-gulp-plugin-error-printer
DEPRECATION
This package has been deprecated. The reason is simply I renamed this project, as the old name "javascript-gulp-plugin-error-printer" is not so good. It should not contains the word "javascript".
The renamed(new) package is @wulechuan/printer-for-errors-of-gulp-plugins. At beginning it's alomst identical to this old one. But it will get supported longer, and will hopefully be very different from this one in the future.
Introduction
This is a message logging plugin for gulp. It parses gulp's PluginError instance, and is expected to print a more beautiful log for the error instance, as long as a parser is provided for that specific type of PluginError.
Almost all colors in the logs are configurable.
Supported Plugins So Far
Even for those errors that are not supported, a beautified property list is logged.
Usage
An Example
See the examples/gulpfile.js
included by this repository as an example.
Below are the key snippet from the said gulpfile.js
.
const printGulpPluginErrorBeautifully = require('..');
const exampleSourceFileBasePath = '.';
const errorOfGlupPluginsPrintingConfigurations = {
// This simply helps the logger print shorter paths
// so that file paths looks better in narrow console windows.
basePathToShortenPrintedFilePaths: exampleSourceFileBasePath,
colorTheme: {
heading: {
lineColor: 'magenta',
},
},
};
function buildCSSStylus (cb) {
return gulpRead(sourceGlobsOfCSSStylus)
.pipe(compileStylus())
.on('error', theError => {
printGulpPluginErrorBeautifully(theError, errorOfGlupPluginsPrintingConfigurations);
cb();
});
}
Try It out, See It in Action
There is a dummy project included within this repository, so that people can try this logger without difficulty.
The said dummy project locates here:
<this repository root folder>/examples
Before You Try
Before you can start trying, you first need to install all dependencies for this npm project.
This is a one time action, you don't need to do it every time before you run the tryout script.
Open a console/terminal and run:
npm install
or even simpler:
npm i
Run the Tryout Script
Open a console/terminal and run:
npm start
or even simpler:
gulp
That's it.
Some Snapshots of Mine
Below are some snapshots of my console, hosted within Microsoft Visual Studio Code.
By the way, the used color theme of my Visual Studio Code, shown in the illustrates below, is the "Panda Theme".
A Stylus compilation error.
A LESSCSS compilation error.
A Sass compilation error.
An UglifyJS parsing error.
Configurations
Currently only colors are configurable. So you may call if "color theme configurations" if you prefer.
See configurations.md.
Known Issues
When utilizing the on('error')
method of a gulp's pipeline,
the error will propagate outside the event handler,
and will finally get printed the traditional way.
Since this logger also prints the error, the error is printed twice.
I'll learn how to swallow the error inside this logger in the future.
API
Sorry. I don't have too much spare time at present. I have my boy to take care of.
Consult my ugly source codes if you'd like to. :p