Skip to content
This repository has been archived by the owner on Sep 29, 2022. It is now read-only.

Commit

Permalink
Fix sasslint errors; update dev-watch.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgerigmeyer committed Jun 30, 2016
1 parent c3b4d21 commit 0a6e94b
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .sass-lint.yml
Expand Up @@ -63,7 +63,7 @@ rules:
function-name-format: 2
hex-length: 2
hex-notation: 2
indentation: 2
indentation: 1
leading-zero:
- 2
- include: true
Expand Down
47 changes: 43 additions & 4 deletions gulpfile.js
Expand Up @@ -8,6 +8,7 @@ const gutil = require('gulp-util');
const path = require('path');
const rename = require('gulp-rename');
const sasslint = require('gulp-sass-lint');
const spawn = require('child_process').spawn;
const svg = require('gulp-svg-symbols');
const svgmin = require('gulp-svgmin');
const webpack = require('webpack');
Expand All @@ -29,6 +30,7 @@ const paths = {
SASS_DIR: 'static/sass/',
ICONS_DIR: 'templates/icons/',
DIST_DIR: 'dev-output/',
PROD_DIST_DIR: 'output/',
IGNORE: [
'!**/.#*',
'!**/flycheck_*'
Expand Down Expand Up @@ -59,6 +61,18 @@ const onError = function (err) {
this.emit('end');
};

// Execute a command, logging output live while process runs
const spawnTask = function (command, args, cb) {
spawned.push(
spawn(command, args, { stdio: 'inherit' })
.on('error', (err) => {
gutil.beep();
return cb(err);
})
.on('exit', cb)
);
};

const eslintTask = (src, failOnError, log) => {
if (log) {
const cmd = `eslint ${src}`;
Expand Down Expand Up @@ -121,12 +135,24 @@ gulp.task('watch', ['webpack-watch'], () => {
// lint all scss when rules change
gulp.watch('**/.sass-lint.yml', ['sasslint-nofail']);

// run webpack to compile static assets
// run webpack to compile styleguide assets
gulp.watch([
`${paths.ICONS_DIR}**/*.svg`,
`${paths.SRC_TEMPLATES_DIR}_icon_template.lodash`,
'./STYLEGUIDE.md'
], ['webpack']);

// compile rstblog assets
gulp.watch([
`${paths.SRC_TEMPLATES_DIR}**/*`,
'content/**/*',
'!content/styleguide/**/*',
'!content/static/assets/**/*',
'!content/static/assets.json',
`!${paths.SRC_TEMPLATES_DIR}_icons.svg`,
`!${paths.ICONS_DIR}**/*.svg`,
`!${paths.SRC_TEMPLATES_DIR}_icon_template.lodash`
], ['dev-build']);
});

gulp.task('eslint', () => eslintTask(paths.ALL_JS, true));
Expand Down Expand Up @@ -167,7 +193,8 @@ gulp.task('browser-sync', (cb) => {
logLevel: 'info',
logPrefix: 'oddsite',
notify: false,
files: [`${paths.DIST_DIR}**/*`]
files: [`${paths.DIST_DIR}**/*`],
reloadDebounce: 200
}, cb);
});

Expand All @@ -185,12 +212,12 @@ const webpackOnBuild = (done) => (err, stats) => {
if (done) { done(err); }
};

gulp.task('webpack', ['sprites'], (cb) => {
gulp.task('webpack', [ 'sprites', 'dev-clean' ], (cb) => {
const webpackConfig = require('./webpack.config.js');
webpack(webpackConfig).run(webpackOnBuild(cb));
});

gulp.task('webpack-prod', ['sprites'], (cb) => {
gulp.task('webpack-prod', [ 'sprites', 'prod-clean' ], (cb) => {
const webpackProdConfig = require('./webpack.prod.config.js');
webpack(webpackProdConfig).run(webpackOnBuild(cb));
});
Expand All @@ -199,3 +226,15 @@ gulp.task('webpack-watch', ['sprites'], () => {
const webpackConfig = require('./webpack.config.js');
webpack(webpackConfig).watch(300, webpackOnBuild());
});

gulp.task('dev-clean', (cb) => {
spawnTask('rm', [ '-rf', paths.DIST_DIR ], cb);
});

gulp.task('prod-clean', (cb) => {
spawnTask('rm', [ '-rf', paths.PROD_DIST_DIR ], cb);
});

gulp.task('dev-build', (cb) => {
spawnTask('python', [ 'run.py', 'dev' ], cb);
});
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -29,7 +29,7 @@
"gulp-chmod": "1.3.0",
"gulp-eslint": "2.0.0",
"gulp-rename": "1.2.2",
"gulp-sass-lint": "1.1.1",
"gulp-sass-lint": "1.2.0",
"gulp-svg-symbols": "1.0.0",
"gulp-svgmin": "1.2.2",
"gulp-util": "3.0.7",
Expand All @@ -38,7 +38,7 @@
"node-sass": "3.8.0",
"postcss-loader": "0.9.1",
"sass-json-export": "2.0.0",
"sass-lint": "1.7.0",
"sass-lint": "1.8.2",
"sass-loader": "4.0.0",
"sassdoc": "2.1.20",
"sassdoc-theme-herman": "0.3.0-alpha.1",
Expand Down

0 comments on commit 0a6e94b

Please sign in to comment.