Skip to content

Commit

Permalink
Update gulp with license tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrleonard committed May 11, 2018
1 parent b96b3fc commit 2c53d8f
Show file tree
Hide file tree
Showing 4 changed files with 21,019 additions and 78 deletions.
67 changes: 37 additions & 30 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ const gulpif = require('gulp-if');
const combiner = require('stream-combiner2');
const bump = require('gulp-bump');
const argv = require('yargs').argv;
const rename = require('gulp-rename');
const sourcemaps = require('gulp-sourcemaps');
const cache = require('gulp-cached');
const exec = require('child_process').exec;
const { ensureLicense } = require('ensure-px-license');

const sassOptions = {
importer: importOnce,
Expand All @@ -42,17 +40,16 @@ const sassOptions = {
};

gulp.task('clean', function() {
return gulp.src(['.tmp', 'css'], {
read: false
}).pipe($.clean());
return gulp.src(['.tmp', 'css'], { read: false })
.pipe($.clean());
});

function handleError(err){
function handleError(err) {
console.log(err.toString());
this.emit('end');
}

function buildCSS(){
function buildCSS() {
return combiner.obj([
$.sass(sassOptions),
$.autoprefixer({
Expand All @@ -66,23 +63,15 @@ function buildCSS(){

gulp.task('sass', function() {
return gulp.src(['./sass/*.scss'])
.pipe(cache('sassing'))
.pipe(buildCSS())
.pipe(stylemod({
moduleId: function(file) {
moduleId(file) {
return path.basename(file.path, path.extname(file.path)) + '-styles';
}
}))
.pipe(ensureLicense())
.pipe(gulp.dest('css'))
.pipe(browserSync.stream({match: 'css/*.html'}));
});

gulp.task('generate-api', function (cb) {
exec(`node_modules/.bin/polymer analyze ${pkg.name}.html > ${pkg.name}-api.json`, function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
.pipe(browserSync.stream({ match: 'css/*.html' }));
});

gulp.task('watch', function() {
Expand All @@ -99,28 +88,46 @@ gulp.task('serve', function() {
server: ['./', 'bower_components'],
});

gulp.watch(['css/*-styles.html', '*.html', '*.js', 'demo/*.html']).on('change', browserSync.reload);
gulp.watch(['sass/*.scss'], ['sass']);
gulp.watch(['css/*-styles.html', '*.html', 'demo/*.html']).on('change', browserSync.reload);
});

gulp.task('bump:patch', function(){
gulp.task('bump:patch', function() {
gulp.src(['./bower.json', './package.json'])
.pipe(bump({type:'patch'}))
.pipe(gulp.dest('./'));
.pipe(bump({ type: 'patch' }))
.pipe(gulp.dest('./'));
});

gulp.task('bump:minor', function(){
gulp.task('bump:minor', function() {
gulp.src(['./bower.json', './package.json'])
.pipe(bump({type:'minor'}))
.pipe(gulp.dest('./'));
.pipe(bump({ type: 'minor' }))
.pipe(gulp.dest('./'));
});

gulp.task('bump:major', function(){
gulp.task('bump:major', function() {
gulp.src(['./bower.json', './package.json'])
.pipe(bump({type:'major'}))
.pipe(gulp.dest('./'));
.pipe(bump({ type: 'major' }))
.pipe(gulp.dest('./'));
});

gulp.task('license', function() {
return gulp.src(['./**/*.{html,js,css,scss}', '!./node_modules/**/*', '!./bower_components?(-1.x)/**/*'])
.pipe(ensureLicense())
.pipe(gulp.dest('.'));
});

gulp.task('default', function(callback) {
gulpSequence('clean', 'sass', 'generate-api')(callback);
gulpSequence('clean', 'sass', 'generate-api', 'license')(callback);
});

/**
* Special task for Polymer component repos. Analyzes the component source code
* and generates documentation in `[component-name]-api.json`.
*/
gulp.task('generate-api', function (cb) {
exec(`node_modules/.bin/polymer analyze ${pkg.name}.html > ${pkg.name}-api.json`, function(err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});
Loading

0 comments on commit 2c53d8f

Please sign in to comment.