├── test ├── fixtures │ ├── 123 │ └── testing ├── expected │ ├── custom_options │ └── default_options └── testing123_test.js ├── .gitignore ├── .jshintrc ├── package.json ├── LICENSE-MIT ├── tasks └── testing123.js ├── Gruntfile.js └── README.md /test/fixtures/123: -------------------------------------------------------------------------------- 1 | 1 2 3 -------------------------------------------------------------------------------- /test/fixtures/testing: -------------------------------------------------------------------------------- 1 | Testing -------------------------------------------------------------------------------- /test/expected/custom_options: -------------------------------------------------------------------------------- 1 | Testing: 1 2 3 !!! -------------------------------------------------------------------------------- /test/expected/default_options: -------------------------------------------------------------------------------- 1 | Testing, 1 2 3. -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | tmp 4 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "curly": true, 3 | "eqeqeq": true, 4 | "immed": true, 5 | "latedef": true, 6 | "newcap": true, 7 | "noarg": true, 8 | "sub": true, 9 | "undef": true, 10 | "boss": true, 11 | "eqnull": true, 12 | "node": true, 13 | "es5": true 14 | } 15 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "grunt-testing123", 3 | "description": "The best Grunt plugin ever.", 4 | "version": "0.1.0", 5 | "homepage": "https://github.com/cowboy/grunt-testing123", 6 | "author": { 7 | "name": "\"Cowboy\" Ben Alman", 8 | "url": "http://benalman.com/" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git://github.com/cowboy/grunt-testing123.git" 13 | }, 14 | "bugs": { 15 | "url": "https://github.com/cowboy/grunt-testing123/issues" 16 | }, 17 | "licenses": [ 18 | { 19 | "type": "MIT", 20 | "url": "https://github.com/cowboy/grunt-testing123/blob/master/LICENSE-MIT" 21 | } 22 | ], 23 | "main": "Gruntfile.js", 24 | "engines": { 25 | "node": ">= 0.8.0" 26 | }, 27 | "scripts": { 28 | "test": "grunt test" 29 | }, 30 | "devDependencies": { 31 | "grunt-contrib-jshint": "~0.1.1", 32 | "grunt-contrib-clean": "~0.4.0", 33 | "grunt-contrib-nodeunit": "~0.1.2", 34 | "grunt": "~0.4.0" 35 | }, 36 | "peerDependencies": { 37 | "grunt": "~0.4.1" 38 | }, 39 | "keywords": [ 40 | "gruntplugin" 41 | ] 42 | } -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 "Cowboy" Ben Alman 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /test/testing123_test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var grunt = require('grunt'); 4 | 5 | /* 6 | ======== A Handy Little Nodeunit Reference ======== 7 | https://github.com/caolan/nodeunit 8 | 9 | Test methods: 10 | test.expect(numAssertions) 11 | test.done() 12 | Test assertions: 13 | test.ok(value, [message]) 14 | test.equal(actual, expected, [message]) 15 | test.notEqual(actual, expected, [message]) 16 | test.deepEqual(actual, expected, [message]) 17 | test.notDeepEqual(actual, expected, [message]) 18 | test.strictEqual(actual, expected, [message]) 19 | test.notStrictEqual(actual, expected, [message]) 20 | test.throws(block, [error], [message]) 21 | test.doesNotThrow(block, [error], [message]) 22 | test.ifError(value) 23 | */ 24 | 25 | exports.testing123 = { 26 | setUp: function(done) { 27 | // setup here if necessary 28 | done(); 29 | }, 30 | default_options: function(test) { 31 | test.expect(1); 32 | 33 | var actual = grunt.file.read('tmp/default_options'); 34 | var expected = grunt.file.read('test/expected/default_options'); 35 | test.equal(actual, expected, 'should describe what the default behavior is.'); 36 | 37 | test.done(); 38 | }, 39 | custom_options: function(test) { 40 | test.expect(1); 41 | 42 | var actual = grunt.file.read('tmp/custom_options'); 43 | var expected = grunt.file.read('test/expected/custom_options'); 44 | test.equal(actual, expected, 'should describe what the custom option(s) behavior is.'); 45 | 46 | test.done(); 47 | }, 48 | }; 49 | -------------------------------------------------------------------------------- /tasks/testing123.js: -------------------------------------------------------------------------------- 1 | /* 2 | * grunt-testing123 3 | * https://github.com/cowboy/grunt-testing123 4 | * 5 | * Copyright (c) 2013 "Cowboy" Ben Alman 6 | * Licensed under the MIT license. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | module.exports = function(grunt) { 12 | 13 | // Please see the Grunt documentation for more information regarding task 14 | // creation: http://gruntjs.com/creating-tasks 15 | 16 | grunt.registerMultiTask('testing123', 'Your task description goes here.', function() { 17 | // Merge task-specific and/or target-specific options with these defaults. 18 | var options = this.options({ 19 | punctuation: '.', 20 | separator: ', ' 21 | }); 22 | 23 | // Iterate over all specified file groups. 24 | this.files.forEach(function(f) { 25 | // Concat specified files. 26 | var src = f.src.filter(function(filepath) { 27 | // Warn on and remove invalid source files (if nonull was set). 28 | if (!grunt.file.exists(filepath)) { 29 | grunt.log.warn('Source file "' + filepath + '" not found.'); 30 | return false; 31 | } else { 32 | return true; 33 | } 34 | }).map(function(filepath) { 35 | // Read file source. 36 | return grunt.file.read(filepath); 37 | }).join(grunt.util.normalizelf(options.separator)); 38 | 39 | // Handle options. 40 | src += options.punctuation; 41 | 42 | // Write the destination file. 43 | grunt.file.write(f.dest, src); 44 | 45 | // Print a success message. 46 | grunt.log.writeln('File "' + f.dest + '" created.'); 47 | }); 48 | }); 49 | 50 | }; 51 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | /* 2 | * grunt-testing123 3 | * https://github.com/cowboy/grunt-testing123 4 | * 5 | * Copyright (c) 2013 "Cowboy" Ben Alman 6 | * Licensed under the MIT license. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | module.exports = function(grunt) { 12 | 13 | // Project configuration. 14 | grunt.initConfig({ 15 | jshint: { 16 | all: [ 17 | 'Gruntfile.js', 18 | 'tasks/*.js', 19 | '<%= nodeunit.tests %>', 20 | ], 21 | options: { 22 | jshintrc: '.jshintrc', 23 | }, 24 | }, 25 | 26 | // Before generating any new files, remove any previously-created files. 27 | clean: { 28 | tests: ['tmp'], 29 | }, 30 | 31 | // Configuration to be run (and then tested). 32 | testing123: { 33 | default_options: { 34 | options: { 35 | }, 36 | files: { 37 | 'tmp/default_options': ['test/fixtures/testing', 'test/fixtures/123'], 38 | }, 39 | }, 40 | custom_options: { 41 | options: { 42 | separator: ': ', 43 | punctuation: ' !!!', 44 | }, 45 | files: { 46 | 'tmp/custom_options': ['test/fixtures/testing', 'test/fixtures/123'], 47 | }, 48 | }, 49 | }, 50 | 51 | // Unit tests. 52 | nodeunit: { 53 | tests: ['test/*_test.js'], 54 | }, 55 | 56 | }); 57 | 58 | // Actually load this plugin's task(s). 59 | grunt.loadTasks('tasks'); 60 | 61 | // These plugins provide necessary tasks. 62 | grunt.loadNpmTasks('grunt-contrib-jshint'); 63 | grunt.loadNpmTasks('grunt-contrib-clean'); 64 | grunt.loadNpmTasks('grunt-contrib-nodeunit'); 65 | 66 | // Whenever the "test" task is run, first clean the "tmp" dir, then run this 67 | // plugin's task(s), then test the result. 68 | grunt.registerTask('test', ['clean', 'testing123', 'nodeunit']); 69 | 70 | // By default, lint and run all tests. 71 | grunt.registerTask('default', ['jshint', 'test']); 72 | 73 | }; 74 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # grunt-testing123 2 | 3 | > The best Grunt plugin ever. 4 | 5 | ## Getting Started 6 | This plugin requires Grunt `~0.4.1` 7 | 8 | If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command: 9 | 10 | ```shell 11 | npm install grunt-testing123 --save-dev 12 | ``` 13 | 14 | Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript: 15 | 16 | ```js 17 | grunt.loadNpmTasks('grunt-testing123'); 18 | ``` 19 | 20 | ## The "testing123" task 21 | 22 | ### Overview 23 | In your project's Gruntfile, add a section named `testing123` to the data object passed into `grunt.initConfig()`. 24 | 25 | ```js 26 | grunt.initConfig({ 27 | testing123: { 28 | options: { 29 | // Task-specific options go here. 30 | }, 31 | your_target: { 32 | // Target-specific file lists and/or options go here. 33 | }, 34 | }, 35 | }) 36 | ``` 37 | 38 | ### Options 39 | 40 | #### options.separator 41 | Type: `String` 42 | Default value: `', '` 43 | 44 | A string value that is used to do something with whatever. 45 | 46 | #### options.punctuation 47 | Type: `String` 48 | Default value: `'.'` 49 | 50 | A string value that is used to do something else with whatever else. 51 | 52 | ### Usage Examples 53 | 54 | #### Default Options 55 | In this example, the default options are used to do something with whatever. So if the `testing` file has the content `Testing` and the `123` file had the content `1 2 3`, the generated result would be `Testing, 1 2 3.` 56 | 57 | ```js 58 | grunt.initConfig({ 59 | testing123: { 60 | options: {}, 61 | files: { 62 | 'dest/default_options': ['src/testing', 'src/123'], 63 | }, 64 | }, 65 | }) 66 | ``` 67 | 68 | #### Custom Options 69 | In this example, custom options are used to do something else with whatever else. So if the `testing` file has the content `Testing` and the `123` file had the content `1 2 3`, the generated result in this case would be `Testing: 1 2 3 !!!` 70 | 71 | ```js 72 | grunt.initConfig({ 73 | testing123: { 74 | options: { 75 | separator: ': ', 76 | punctuation: ' !!!', 77 | }, 78 | files: { 79 | 'dest/default_options': ['src/testing', 'src/123'], 80 | }, 81 | }, 82 | }) 83 | ``` 84 | 85 | ## Contributing 86 | In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/). 87 | 88 | ## Release History 89 | _(Nothing yet)_ 90 | --------------------------------------------------------------------------------