Skip to content

Instantly share code, notes, and snippets.

@mikeerickson
Last active February 24, 2017 22:43
Show Gist options
  • Save mikeerickson/a51fd271ad9d65f04b1d4b948cb50cc6 to your computer and use it in GitHub Desktop.
Save mikeerickson/a51fd271ad9d65f04b1d4b948cb50cc6 to your computer and use it in GitHub Desktop.
Node Script to watch sass files and execute sass-lint on changes
/* global require */
// requires chokidar, execa, cd-messenger, sass-lint and chalk
let chokidar = require('chokidar');
let execa = require('execa');
let msg = require('cd-messenger');
let chalk = require('chalk');
let srcFiles = './src/sass/*.scss';
let sassLintBin = './node_modules/.bin/sass-lint';
msg.log(chalk.bold.cyan('\n==> Watching ' + srcFiles));
chokidar.watch(srcFiles, {ignored: /[\/\\]\./}).on('all', (event, path) => {
execa(sassLintBin, [path, '-v -p'], {stdio: 'inherit'})
.then(result => {
console.log('');
msg.success('Sass Linting Complete... \n');
})
.catch(result => {
if(result.stderr) {
msg.error(result.stderr);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment