Last active
February 24, 2017 22:43
-
-
Save mikeerickson/a51fd271ad9d65f04b1d4b948cb50cc6 to your computer and use it in GitHub Desktop.
Node Script to watch sass files and execute sass-lint on changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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