Skip to content

Commit

Permalink
moved debugging into --debug flag
Browse files Browse the repository at this point in the history
use dbg('title') for debug access
  • Loading branch information
Dan Lasky authored and Shuwen Qian committed Mar 3, 2016
1 parent 9935c40 commit ff011bf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
33 changes: 26 additions & 7 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var run = require('run-sequence');

//gulp plugins
var gutil = require('gulp-util');
var gif = require('gulp-if');
var sass = require('gulp-sass');
var rename = require('gulp-rename');
var vulcanize = require('gulp-vulcanize');
Expand Down Expand Up @@ -60,11 +61,18 @@ var PATCH_LIST = [
'bower_components/moment/min/moment.min.js'
];

var IS_DEBUG = !!gutil.env.debug;
console.log(IS_DEBUG);

function dbg(t) {
return gif(IS_DEBUG, debug({title:t}));
}

/** BUILD **/

gulp.task('patch-lib', function() {
gulp.src(PATCH_LIST, {base: j(__dirname, 'bower_components')})
.pipe(debug())
.pipe(dbg('patch-lib'))
.pipe(wrap("(function(define, require) { {{{contents}}} })();",{},{engine:"hogan"}).on('error',console.error))
.pipe(gulp.dest( j(__dirname, 'bower_components') ));
});
Expand All @@ -80,7 +88,7 @@ gulp.task('clean:dist', function() {
gulp.task('copy', function() {
return gulp.src([j(SRC,'**/*.+(html|js|woff)'), j('!',SRC,'**/example.html')])
.pipe(cache('copy'))
.pipe(debug())
.pipe(dbg('copy'))
.pipe(gulp.dest(BUILD));
});

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

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

Expand Down Expand Up @@ -151,7 +163,7 @@ gulp.task('vulcanize', function() {
inlineCss: true,
implicitStrip: false
}, excludes, BUILD))
.pipe(debug())
.pipe(dbg('vulcanize-modules'))
.pipe(htmlmin())
.pipe(gulp.dest(BUILD));

Expand All @@ -160,6 +172,7 @@ gulp.task('vulcanize', function() {
inlineScripts: true,
inlineCss: true
}))
.pipe(dbg('vulcanize-lib'))
.pipe(gulp.dest(BUILD));
return merge(modules, lib);
});
Expand Down Expand Up @@ -190,6 +203,7 @@ gulp.task('build:prod', ['patch-lib', 'build'], function() {
}))
.pipe(inlinemin())
.pipe(header('<!--\n' + fs.readFileSync('BANNER.txt','utf8') + ' -->'))
.pipe(dbg('vulcanize-modules'))
.pipe(gulp.dest(DIST));

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

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

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

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

return merge(bower_components, merged_static, lib);
});

gulp.task('sass:docs', function() {
return gulp.src('docs/**/*.scss')
.pipe(dbg('sass-docs'))
.pipe(sass({includePaths: ['./bower_components/bourbon/app/assets/stylesheets/', './src/shared/sass/']}).on('error', sass.logError))
.pipe(postcss([autoprefixer({browsers: ['last 2 versions']})]))
.pipe(gulp.dest(BUILD_DOCS));
Expand Down Expand Up @@ -415,7 +432,7 @@ gulp.task('docs:templates', function() {
.pipe(cache('docs_module'))
.pipe(injectBehaviorDocs(behaviorsMap))
.pipe(injectModuleData(pkg, moduleMap, articleList, articleMap))
// .pipe(debug())
.pipe(dbg('docs-modules'))
.pipe(through.obj(function(file, enc, cb) {
var moduleDoc = JSON.parse(file.contents);
var templatePath = path.join(__dirname,'docs/component_template.html');
Expand All @@ -439,6 +456,7 @@ gulp.task('docs:templates', function() {
.pipe(marked().on('error',console.log))
.pipe(injectArticleData(pkg, moduleMap, articleList, articleMap))
.pipe(rename({prefix: 'article_'}))
.pipe(dbg('docs-articles'))
.pipe(gulp.dest(BUILD_DOCS));

return merge(indexStream, moduleStream, articleStream);
Expand All @@ -447,6 +465,7 @@ gulp.task('docs:templates', function() {
gulp.task('gh-pages', function() {
var pkg = getPkgInfo();
return gulp.src(BUILD_DOCS+'**/*')
.pipe(dbg('gh-pages'))
.pipe(ghPages({
message: 'docs updates v'+pkg.version
}));
Expand All @@ -467,7 +486,7 @@ gulp.task('index', function() {
var templateString = fs.readFileSync(templatePath).toString('utf8');
var template = hogan.compile(templateString);
var index = template.render(moduleMap);
fs.writeFileSync(path.join(BUILD,'index.html'), index);
fs.writeFileSync(j(BUILD,'index.html'), index);
});

gulp.task('server', function() {
Expand Down Expand Up @@ -540,7 +559,7 @@ gulp.task('changelog', function() {
}
}
}))
.pipe(debug())
.pipe(dbg('changelog'))
.pipe(gulp.dest('.'));
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"gulp-gh-pages": "^0.5.4",
"gulp-git": "^1.7.0",
"gulp-header": "^1.7.1",
"gulp-if": "^2.0.0",
"gulp-inline-assets": "^0.1.1",
"gulp-marked": "^1.0.0",
"gulp-minify-html": "^1.0.5",
Expand All @@ -48,6 +49,5 @@
"serve-static": "^1.10.2",
"through2": "^2.0.1",
"vulcanize": "^1.14.6"

}
}

0 comments on commit ff011bf

Please sign in to comment.