Skip to content

Commit

Permalink
add grunt watch task, closes thomaspark#281
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaspark committed Jul 7, 2014
1 parent 2524e18 commit b09a03a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
15 changes: 15 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
builddir: '.',
buildtheme: '',
banner: '/*!\n' +
' * <%= pkg.name %> v<%= pkg.version %>\n' +
' * Homepage: <%= pkg.homepage %>\n' +
Expand Down Expand Up @@ -43,12 +44,20 @@ module.exports = function (grunt) {
},
files: {}
}
},
watch: {
files: ['*/variables.less', '*/bootswatch.less'],
tasks: 'build',
options: {
nospawn: true
}
}
});

grunt.registerTask('none', function() {});

grunt.registerTask('build', 'build a regular theme', function(theme, compress) {
var theme = theme == undefined ? grunt.config('buildtheme') : theme;
var compress = compress == undefined ? true : compress;

var concatSrc;
Expand Down Expand Up @@ -89,4 +98,10 @@ module.exports = function (grunt) {
grunt.registerTask('default', 'build a theme', function() {
grunt.task.run('swatch');
});

grunt.event.on('watch', function(action, filepath) {
var path = require('path');
var theme = path.dirname(filepath);
grunt.config('buildtheme', theme);
});
};
5 changes: 2 additions & 3 deletions help/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,9 @@ <h1 id="customization">Customization</h1>
<ol>
<li><p><code>git clone https://github.com/thomaspark/bootswatch.git</code></p></li>
<li><p><code>npm install</code></p></li>
<li>
<p>Edit <code>variables.less</code> and <code>bootswatch.less</code> in one of the theme directories, or create your own in <code>/custom</code>.</p>
</li>
<li><p>Edit <code>variables.less</code> and <code>bootswatch.less</code> in one of the theme directories, or create your own in <code>/custom</code>.</p></li>
<li><p>Type <code>grunt swatch:[theme]</code> to build the CSS for a theme, e.g., <code>grunt swatch:amelia</code> for Amelia. Or type <code>grunt swatch</code> to build them all at once. To have <code>grunt</code> available in the command line, install <code>grunt-cli</code> as described on the <a href="http://gruntjs.com/getting-started">Grunt Getting Started page</a>.</p></li>
<li><p>You can also run <code>grunt watch</code> to watch for any changes to the LESS files and automatically build a theme on change.</p></li>
</ol>
<p>Here are additional tips for <a href="http://coding.smashingmagazine.com/2013/03/12/customizing-bootstrap/" target="_blank">customizing Bootstrap</a>.</p>
</div>
Expand Down

0 comments on commit b09a03a

Please sign in to comment.