parent
ed8364741b
commit
e50f537667
14
gulpfile.js
14
gulpfile.js
@ -34,7 +34,19 @@ var util = require('./tools/build/util');
|
|||||||
var bundler = require('./tools/build/bundle');
|
var bundler = require('./tools/build/bundle');
|
||||||
var replace = require('gulp-replace');
|
var replace = require('gulp-replace');
|
||||||
var insert = require('gulp-insert');
|
var insert = require('gulp-insert');
|
||||||
|
var shouldLog = require('./tools/build/logging');
|
||||||
|
|
||||||
|
// Make it easy to quiet down portions of the build.
|
||||||
|
// --logs=all -> log everything (This is the default)
|
||||||
|
// --logs=quiet -> log nothing
|
||||||
|
// --logs=<comma-separated-list> -> log listed items.
|
||||||
|
//
|
||||||
|
// Not all commands support optional logging, feel free
|
||||||
|
// to add support by adding a new key to this list,
|
||||||
|
// and toggling output from the command based on it.
|
||||||
|
var logs = {
|
||||||
|
dartfmt: shouldLog('dartfmt')
|
||||||
|
};
|
||||||
|
|
||||||
// dynamic require in build.tools so we can bootstrap TypeScript compilation
|
// dynamic require in build.tools so we can bootstrap TypeScript compilation
|
||||||
function throwToolsBuildMissingError() {
|
function throwToolsBuildMissingError() {
|
||||||
@ -194,7 +206,7 @@ gulp.task('build/pubbuild.dart', pubbuild(gulp, gulpPlugins, {
|
|||||||
|
|
||||||
gulp.task('build/format.dart', function() {
|
gulp.task('build/format.dart', function() {
|
||||||
return util.processToPromise(spawn(DART_SDK.DARTFMT, ['-w', CONFIG.dest.dart], {
|
return util.processToPromise(spawn(DART_SDK.DARTFMT, ['-w', CONFIG.dest.dart], {
|
||||||
stdio: 'inherit'
|
stdio: logs.dartfmt ? 'inherit' : ['ignore', 'ignore', 'inherit']
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
43
tools/build/logging.js
Normal file
43
tools/build/logging.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
var kLogsArgument = /^--logs\s*=\s*(.+?)$/;
|
||||||
|
var kTrimLeft = /^\s+/;
|
||||||
|
var kTrimRight = /\s+$/;
|
||||||
|
var kCamelCase = /[-_\s]+(.)?/g;
|
||||||
|
var logs = findArgvLogs();
|
||||||
|
|
||||||
|
function findArgvLogs() {
|
||||||
|
for (var i = 0; i < process.argv.length; ++i) {
|
||||||
|
var match = process.argv[i].match(kLogsArgument);
|
||||||
|
if (match) {
|
||||||
|
return logsToObject(match[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function logsToObject(logstr) {
|
||||||
|
return logstr.
|
||||||
|
split(',').
|
||||||
|
reduce(function(obj, key) {
|
||||||
|
key = camelize(key);
|
||||||
|
if (key.length > 0) obj[key] = true;
|
||||||
|
return obj;
|
||||||
|
}, Object.create(null));
|
||||||
|
return logs;
|
||||||
|
}
|
||||||
|
|
||||||
|
function camelize(str) {
|
||||||
|
return str.
|
||||||
|
replace(kTrimLeft, '').
|
||||||
|
replace(kTrimRight, '').
|
||||||
|
replace(kCamelCase, function(match, c) {
|
||||||
|
return c ? c.toUpperCase() : "";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function shouldLog(str) {
|
||||||
|
if (!logs || logs.quiet) return false;
|
||||||
|
if (logs.all) return true;
|
||||||
|
return !!logs[camelize(str)];
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = shouldLog;
|
Loading…
x
Reference in New Issue
Block a user