This repository is part of the JavaScript Application Design: A Build First Approach book's code samples, the full original for the code samples can be found here. You can learn more about the book itself here.
This tutorial is part of the code samples accompanying the book in the appendix Introduction to Grunt, which walks you through the kind of things you can do, using Grunt.
You might want to create your own Grunt tasks to help you shape your workflows. This example shows you how to do just that.
For the code in the book to work as a Grunt plugin, I just placed it inside an exported task function, like below.
module.exports = function (grunt) {
// register task
};
Which is pretty much the same pattern we see in a Gruntfile.js
. Learn more about Grunt plugins here.
The walkthrough itself can be found in the book.
Below is how this README would actually look like if I were serious about open-sourcing it.
Grunt task to count words and set a word count threshold.
Check for updates in the changelog.
To consume it, install it from npm
.
npm i -D grunt-wordcount
Read quick tips about npm.
Pick which files to count words from. Provide an optional threshold
. If a threshold
is provided, the task will fail unless it counts less words than that.
wordcount: {
everything: {
files: {
src: ['**/*', '!node_modules/**']
}
},
capped: {
files: {
src: ['**/*', '!node_modules/**']
},
options: {
threshold: 30
}
}
}
Just the threshold
for now.
MIT