Skip to content

Commit ff011bf

Browse files
Dan LaskyShuwen Qian
authored andcommitted
moved debugging into --debug flag
use dbg('title') for debug access
1 parent 9935c40 commit ff011bf

2 files changed

Lines changed: 27 additions & 8 deletions

File tree

Gulpfile.js

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var run = require('run-sequence');
2525

2626
//gulp plugins
2727
var gutil = require('gulp-util');
28+
var gif = require('gulp-if');
2829
var sass = require('gulp-sass');
2930
var rename = require('gulp-rename');
3031
var vulcanize = require('gulp-vulcanize');
@@ -60,11 +61,18 @@ var PATCH_LIST = [
6061
'bower_components/moment/min/moment.min.js'
6162
];
6263

64+
var IS_DEBUG = !!gutil.env.debug;
65+
console.log(IS_DEBUG);
66+
67+
function dbg(t) {
68+
return gif(IS_DEBUG, debug({title:t}));
69+
}
70+
6371
/** BUILD **/
6472

6573
gulp.task('patch-lib', function() {
6674
gulp.src(PATCH_LIST, {base: j(__dirname, 'bower_components')})
67-
.pipe(debug())
75+
.pipe(dbg('patch-lib'))
6876
.pipe(wrap("(function(define, require) { {{{contents}}} })();",{},{engine:"hogan"}).on('error',console.error))
6977
.pipe(gulp.dest( j(__dirname, 'bower_components') ));
7078
});
@@ -80,7 +88,7 @@ gulp.task('clean:dist', function() {
8088
gulp.task('copy', function() {
8189
return gulp.src([j(SRC,'**/*.+(html|js|woff)'), j('!',SRC,'**/example.html')])
8290
.pipe(cache('copy'))
83-
.pipe(debug())
91+
.pipe(dbg('copy'))
8492
.pipe(gulp.dest(BUILD));
8593
});
8694

@@ -90,21 +98,25 @@ gulp.task('sass', function() {
9098
.pipe(cache('scss'))
9199
.pipe(sass({includePaths: ['./bower_components/bourbon/app/assets/stylesheets/', './src/shared/sass/']}).on('error', sass.logError))
92100
.pipe(postcss([autoprefixer({browsers: ['last 2 versions']})]))
101+
.pipe(dbg('sass'))
93102
.pipe(gulp.dest(BUILD))
94103
.pipe(wrap(function(data) {
95104
data.fname = path.basename(data.file.relative,'.css');
96105
return wrapper;
97106
},{},{engine:"hogan"}))
98107
.pipe(rename({basename:"style", extname: ".html"}))
108+
.pipe(dbg('sass-html'))
99109
.pipe(gulp.dest(BUILD));
100110
});
101111

102112
gulp.task('font', function() {
103113
return gulp.src(SRC + 'shared/fonts/fonts.scss')
104114
.pipe(sass({includePaths: ['./bower_components/bourbon/app/assets/stylesheets/', './src/shared/sass/']}).on('error', sass.logError))
115+
.pipe(dbg('font'))
105116
.pipe(gulp.dest(BUILD + 'shared/fonts/'))
106117
.pipe(wrap("<style>{{{contents}}}</style>",{},{engine:"hogan"}).on('error',console.log))
107118
.pipe(rename("fonts.html").on('error',console.log))
119+
.pipe(dbg('font-output'))
108120
.pipe(gulp.dest(j(BUILD,'/shared/fonts/')));
109121
});
110122

@@ -151,7 +163,7 @@ gulp.task('vulcanize', function() {
151163
inlineCss: true,
152164
implicitStrip: false
153165
}, excludes, BUILD))
154-
.pipe(debug())
166+
.pipe(dbg('vulcanize-modules'))
155167
.pipe(htmlmin())
156168
.pipe(gulp.dest(BUILD));
157169

@@ -160,6 +172,7 @@ gulp.task('vulcanize', function() {
160172
inlineScripts: true,
161173
inlineCss: true
162174
}))
175+
.pipe(dbg('vulcanize-lib'))
163176
.pipe(gulp.dest(BUILD));
164177
return merge(modules, lib);
165178
});
@@ -190,6 +203,7 @@ gulp.task('build:prod', ['patch-lib', 'build'], function() {
190203
}))
191204
.pipe(inlinemin())
192205
.pipe(header('<!--\n' + fs.readFileSync('BANNER.txt','utf8') + ' -->'))
206+
.pipe(dbg('vulcanize-modules'))
193207
.pipe(gulp.dest(DIST));
194208

195209
var lib = gulp.src(j(BUILD,'strand.html'))
@@ -206,6 +220,7 @@ gulp.task('build:prod', ['patch-lib', 'build'], function() {
206220
}))
207221
.pipe(inlinemin())
208222
.pipe(header('<!--\n' + fs.readFileSync('BANNER.txt','utf8') + ' -->'))
223+
.pipe(dbg('vulcanize-lib'))
209224
.pipe(gulp.dest(DIST));
210225

211226
return merge(modules, lib);
@@ -227,17 +242,19 @@ gulp.task('copy:docs', function() {
227242
.pipe(gulp.dest(BUILD_DOCS));
228243

229244
var bower_components = gulp.src(['bower_components/webcomponentsjs/**/*', 'bower_components/polymer/**/*'], {base:'bower_components'})
230-
.pipe(debug())
245+
.pipe(dbg('copy-bower'))
231246
.pipe(gulp.dest(BUILD_DOCS+'/bower_components/'));
232247

233248
var lib = gulp.src(j(BUILD,'**'))
249+
.pipe(dbg('copy-lib'))
234250
.pipe(gulp.dest(j(BUILD_DOCS,'/bower_components/strand/dist')));
235251

236252
return merge(bower_components, merged_static, lib);
237253
});
238254

239255
gulp.task('sass:docs', function() {
240256
return gulp.src('docs/**/*.scss')
257+
.pipe(dbg('sass-docs'))
241258
.pipe(sass({includePaths: ['./bower_components/bourbon/app/assets/stylesheets/', './src/shared/sass/']}).on('error', sass.logError))
242259
.pipe(postcss([autoprefixer({browsers: ['last 2 versions']})]))
243260
.pipe(gulp.dest(BUILD_DOCS));
@@ -415,7 +432,7 @@ gulp.task('docs:templates', function() {
415432
.pipe(cache('docs_module'))
416433
.pipe(injectBehaviorDocs(behaviorsMap))
417434
.pipe(injectModuleData(pkg, moduleMap, articleList, articleMap))
418-
// .pipe(debug())
435+
.pipe(dbg('docs-modules'))
419436
.pipe(through.obj(function(file, enc, cb) {
420437
var moduleDoc = JSON.parse(file.contents);
421438
var templatePath = path.join(__dirname,'docs/component_template.html');
@@ -439,6 +456,7 @@ gulp.task('docs:templates', function() {
439456
.pipe(marked().on('error',console.log))
440457
.pipe(injectArticleData(pkg, moduleMap, articleList, articleMap))
441458
.pipe(rename({prefix: 'article_'}))
459+
.pipe(dbg('docs-articles'))
442460
.pipe(gulp.dest(BUILD_DOCS));
443461

444462
return merge(indexStream, moduleStream, articleStream);
@@ -447,6 +465,7 @@ gulp.task('docs:templates', function() {
447465
gulp.task('gh-pages', function() {
448466
var pkg = getPkgInfo();
449467
return gulp.src(BUILD_DOCS+'**/*')
468+
.pipe(dbg('gh-pages'))
450469
.pipe(ghPages({
451470
message: 'docs updates v'+pkg.version
452471
}));
@@ -467,7 +486,7 @@ gulp.task('index', function() {
467486
var templateString = fs.readFileSync(templatePath).toString('utf8');
468487
var template = hogan.compile(templateString);
469488
var index = template.render(moduleMap);
470-
fs.writeFileSync(path.join(BUILD,'index.html'), index);
489+
fs.writeFileSync(j(BUILD,'index.html'), index);
471490
});
472491

473492
gulp.task('server', function() {
@@ -540,7 +559,7 @@ gulp.task('changelog', function() {
540559
}
541560
}
542561
}))
543-
.pipe(debug())
562+
.pipe(dbg('changelog'))
544563
.pipe(gulp.dest('.'));
545564
});
546565

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"gulp-gh-pages": "^0.5.4",
2929
"gulp-git": "^1.7.0",
3030
"gulp-header": "^1.7.1",
31+
"gulp-if": "^2.0.0",
3132
"gulp-inline-assets": "^0.1.1",
3233
"gulp-marked": "^1.0.0",
3334
"gulp-minify-html": "^1.0.5",
@@ -48,6 +49,5 @@
4849
"serve-static": "^1.10.2",
4950
"through2": "^2.0.1",
5051
"vulcanize": "^1.14.6"
51-
5252
}
5353
}

0 commit comments

Comments
 (0)