-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Log gulp error to Chart.js #5143
Changes from 9 commits
142e19d
58bb9fe
2414daa
08cf096
d2327ef
ecffc82
e490438
e21587b
ae0e7e7
c8388d6
251fcc3
0b39c03
6ad9149
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ var collapse = require('bundle-collapser/plugin'); | |
var argv = require('yargs').argv | ||
var path = require('path'); | ||
var package = require('./package.json'); | ||
var fs = require('fs'); | ||
var minimist = require('minimist'); | ||
|
||
var srcDir = './src/'; | ||
var outDir = './dist/'; | ||
|
@@ -34,6 +36,9 @@ var header = "/*!\n" + | |
" * https://github.com/chartjs/Chart.js/blob/master/LICENSE.md\n" + | ||
" */\n"; | ||
|
||
var options = minimist(process.argv.slice(2)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already depend on yargs, no need for minimist: var argv = require('yargs')
.option('force-output', {default: 'false'})
.option('silent-errors', {default: 'false'})
.option('verbose', {default: 'false'})
.argv;
// ...
if (argv.forceOutput) { ... }
if (argv.silentErrors) { ... } |
||
util.log("Gulp running with options: "+JSON.stringify(options, null, 2)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if (argv.verbose) {
util.log("Gulp running with options: " + JSON.stringify(argv, null, 2));
} |
||
|
||
gulp.task('bower', bowerTask); | ||
gulp.task('build', buildTask); | ||
gulp.task('package', packageTask); | ||
|
@@ -79,9 +84,25 @@ function bowerTask() { | |
|
||
function buildTask() { | ||
|
||
var errorHandler = function (err) { | ||
util.log(util.colors.red('[Error]'), err.toString()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would move that line before |
||
if(options['force-output']) { | ||
var browserError = 'console.error("Gulp: ' + err.toString() + '")'; | ||
['Chart', 'Chart.min', 'Chart.bundle', 'Chart.bundle.min'].forEach(function(fileName) { | ||
fs.writeFileSync(outDir+fileName+'.js', browserError); | ||
}); | ||
} | ||
if(options['silent-errors']) { | ||
this.emit('end'); | ||
} else { | ||
throw err; | ||
} | ||
} | ||
|
||
var bundled = browserify('./src/chart.js', { standalone: 'Chart' }) | ||
.plugin(collapse) | ||
.bundle() | ||
.on('error', errorHandler) | ||
.pipe(source('Chart.bundle.js')) | ||
.pipe(insert.prepend(header)) | ||
.pipe(streamify(replace('{{ version }}', package.version))) | ||
|
@@ -96,6 +117,7 @@ function buildTask() { | |
.ignore('moment') | ||
.plugin(collapse) | ||
.bundle() | ||
.on('error', errorHandler) | ||
.pipe(source('Chart.js')) | ||
.pipe(insert.prepend(header)) | ||
.pipe(streamify(replace('{{ version }}', package.version))) | ||
|
@@ -135,15 +157,15 @@ function lintTask() { | |
// NOTE(SB) codeclimate has 'complexity' and 'max-statements' eslint rules way too strict | ||
// compare to what the current codebase can support, and since it's not straightforward | ||
// to fix, let's turn them as warnings and rewrite code later progressively. | ||
var options = { | ||
var eslintOptions = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to rename this variable, we can keep |
||
rules: { | ||
'complexity': [1, 10], | ||
'max-statements': [1, 30] | ||
} | ||
}; | ||
|
||
return gulp.src(files) | ||
.pipe(eslint(options)) | ||
.pipe(eslint(eslintOptions)) | ||
.pipe(eslint.format()) | ||
.pipe(eslint.failAfterError()); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] can we move
var fs
beforevar package
since the later one is a local file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
while i'm at it, is there any logic in the order for the non local dependencies ? alphabetical, date of addition ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No guideline for the order because some require() may need other ones. I'm used to gather related dependencies (e.g.
gulp-*
) and declare thepackage.json
at the end.