From 44abe380e440e2b73f0e05ebc07d15ba06db2156 Mon Sep 17 00:00:00 2001 From: Tyler Kellen Date: Mon, 17 Sep 2012 16:01:19 -0500 Subject: [PATCH] first commit --- .gitignore | 3 ++ AUTHORS | 2 ++ LICENSE-MIT | 22 +++++++++++++ README.md | 21 ++++++++++++ grunt.js | 65 ++++++++++++++++++++++++++++++++++++++ package.json | 40 +++++++++++++++++++++++ tasks/watch.js | 32 +++++++++++++++++++ test/expected/compile.css | 1 + test/fixtures/compile.sass | 1 + test/watch_test.js | 14 ++++++++ 10 files changed, 201 insertions(+) create mode 100644 .gitignore create mode 100644 AUTHORS create mode 100644 LICENSE-MIT create mode 100644 README.md create mode 100644 grunt.js create mode 100644 package.json create mode 100644 tasks/watch.js create mode 100644 test/expected/compile.css create mode 100644 test/fixtures/compile.sass create mode 100644 test/watch_test.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b785247 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules +npm-debug.log +tmp diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..fed3e5e --- /dev/null +++ b/AUTHORS @@ -0,0 +1,2 @@ +Ben Alman (http://benalman.com) +Kyle Robinson Young (http://dontkry.com) diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000..cfb088b --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,22 @@ +Copyright (c) 2012 Ben Alman, contributors. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..50af4de --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# grunt-contrib-watch (not released) +> Your description here (part of the [grunt-contrib](https://github.com/gruntjs/grunt-contrib) collection). Submitted by [Sindre Sorhus](/sindresorhus). + +## Getting Started +Install this grunt plugin next to your project's [grunt.js gruntfile][getting_started] with: `npm install grunt-contrib-watch` + +Then add this line to your project's `grunt.js` gruntfile: + +```javascript +grunt.loadNpmTasks('grunt-contrib-watch'); +``` + +[grunt]: https://github.com/cowboy/grunt +[getting_started]: https://github.com/cowboy/grunt/blob/master/docs/getting_started.md + +### Overview + + +## Release History + +* 2012/08/xx - v0.2.0 - notation diff --git a/grunt.js b/grunt.js new file mode 100644 index 0000000..7f5fd54 --- /dev/null +++ b/grunt.js @@ -0,0 +1,65 @@ +/* + * grunt-contrib-watch + * http://gruntjs.com/ + * + * Copyright (c) 2012 Sindre Sorhus, contributors + * Licensed under the MIT license. + * https://github.com/gruntjs/grunt-contrib-watch/blob/master/LICENSE-MIT + */ + +module.exports = function(grunt) { + 'use strict'; + + // Project configuration. + grunt.initConfig({ + lint: { + all: ['grunt.js', 'tasks/*.js', ''] + }, + + jshint: { + options: { + curly: true, + eqeqeq: true, + immed: true, + latedef: true, + newcap: true, + noarg: true, + sub: true, + undef: true, + boss: true, + eqnull: true, + node: true, + es5: true + } + }, + + // Before generating any new files, remove any previously-created files. + clean: { + test: ['tmp'] + }, + + // Configuration to be run (and then tested). + watch: { + + }, + + // Unit tests. + nodeunit: { + tasks: ['test/*_test.js'] + } + }); + + // Actually load this plugin's task(s). + grunt.loadTasks('tasks'); + + // The clean plugin helps in testing. + grunt.loadNpmTasks('grunt-contrib-clean'); + + // Whenever the "test" task is run, first clean the "tmp" dir, then run this + // plugin's task(s), then test the result. + grunt.renameTask('test', 'nodeunit'); + grunt.registerTask('test', 'clean watch nodeunit'); + + // By default, lint and run all tests. + grunt.registerTask('default', 'lint test'); +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..c403b8f --- /dev/null +++ b/package.json @@ -0,0 +1,40 @@ +{ + "name": "grunt-contrib-watch", + "description": "Your description here.", + "version": "0.2.0", + "homepage": "https://github.com/gruntjs/grunt-contrib-watch", + "author": { + "name": "Ben Alman", + "url": "http://benalman.com" + }, + "repository": { + "type": "git", + "url": "git://github.com/gruntjs/grunt-contrib-watch.git" + }, + "bugs": { + "url": "https://github.com/gruntjs/grunt-contrib-watch/issues" + }, + "licenses": [ + { + "type": "MIT", + "url": "https://github.com/gruntjs/grunt-contrib-watch/blob/master/LICENSE-MIT" + } + ], + "main": "grunt.js", + "engines": { + "node": "*" + }, + "scripts": { + "test": "grunt test" + }, + "dependencies": { + "grunt-contrib-lib": "~0.2.0" + }, + "devDependencies": { + "grunt": "~0.3.15", + "grunt-contrib-clean": "~0.2.0" + }, + "keywords": [ + "gruntplugin" + ] +} diff --git a/tasks/watch.js b/tasks/watch.js new file mode 100644 index 0000000..fb852f2 --- /dev/null +++ b/tasks/watch.js @@ -0,0 +1,32 @@ +/* + * grunt-contrib-watch + * http://gruntjs.com/ + * + * Copyright (c) 2012 Ben Alman, contributors + * Licensed under the MIT license. + * https://github.com/gruntjs/grunt-contrib-watch/blob/master/LICENSE-MIT + */ + +module.exports = function(grunt) { + 'use strict'; + + // TODO: ditch this when grunt v0.4 is released + grunt.util = grunt.util || grunt.utils; + + var _ = grunt.util._; + var helpers = require('grunt-contrib-lib').init(grunt); + + grunt.registerMultiTask('watch', '', function() { + + var helpers = require('grunt-contrib-lib').init(grunt); + var options = helpers.options(this, {namespace: 'JST'}); + + grunt.verbose.writeflags(options, 'Options'); + + // TODO: ditch this when grunt v0.4 is released + this.files = this.files || helpers.normalizeMultiTaskFiles(this.data, this.target); + + + }); + +}; diff --git a/test/expected/compile.css b/test/expected/compile.css new file mode 100644 index 0000000..ab5f11c --- /dev/null +++ b/test/expected/compile.css @@ -0,0 +1 @@ +body{} \ No newline at end of file diff --git a/test/fixtures/compile.sass b/test/fixtures/compile.sass new file mode 100644 index 0000000..ab5f11c --- /dev/null +++ b/test/fixtures/compile.sass @@ -0,0 +1 @@ +body{} \ No newline at end of file diff --git a/test/watch_test.js b/test/watch_test.js new file mode 100644 index 0000000..40e88ec --- /dev/null +++ b/test/watch_test.js @@ -0,0 +1,14 @@ +var grunt = require('grunt'); + +exports.watch = { + compile: function(test) { + 'use strict'; + test.expect(1); + + var actual = grunt.file.read('tmp/compile.css'); + var expected = grunt.file.read('test/expected/compile.css'); + test.equal(actual, expected, 'should compile watch to css using watch'); + + test.done(); + } +};