Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial commit

Signed-off-by: Christopher Rogers <chrissrogers@gmail.com>
  • Loading branch information...
commit 5f438d1e2b85ad2a20b504b57afabfdcc374a6d0 0 parents
@chrissrogers authored
22 LICENSE-MIT
@@ -0,0 +1,22 @@
+Copyright (c) 2012 Christopher Rogers
+
+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.
47 README.md
@@ -0,0 +1,47 @@
+# grunt-wrap
+
+Wraps text files
+
+## Getting Started
+Install this grunt plugin next to your project's [grunt.js gruntfile][getting_started] with: ``npm install grunt-wrap``
+
+Then add this line to your project's ``grunt.js`` gruntfile:
+
+```javascript
+grunt.loadNpmTasks('grunt-wrap');
+```
+
+[grunt]: https://github.com/cowboy/grunt
+[getting_started]: https://github.com/cowboy/grunt/blob/master/docs/getting_started.md
+
+## Documentation
+Configure which files to be copied in your `initConfig`:
+
+```javascript
+grunt.initConfig({
+
+ // ... other configs
+
+ // wrap my modules with define
+ wrap: {
+ modules: {
+ src: ['assets/*.js'],
+ dest: 'dist/',
+ wrapper: ['define(function (require, exports, module) {\n', '\n});']
+ }
+ },
+
+ // ... other configs
+});
+```
+
+## Contributing
+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][grunt].
+
+## Release History
+* 2012 Oct 4 - v0.1.0 - Initial release.
+
+## License
+Copyright (c) 2012 Christopher Rogers
+Licensed under the MIT license.
2  bin/grunt-cp
@@ -0,0 +1,2 @@
+#!/usr/bin/env node
+require('grunt').npmTasks('grunt-cp').cli();
40 grunt.js
@@ -0,0 +1,40 @@
+module.exports = function(grunt) {
+
+ // Project configuration.
+ grunt.initConfig({
+ test: {
+ files: ['test/**/*.js']
+ },
+ lint: {
+ files: ['grunt.js', 'tasks/**/*.js', 'test/**/*.js']
+ },
+ watch: {
+ files: '<config:lint.files>',
+ tasks: 'default'
+ },
+ 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
+ },
+ globals: {}
+ }
+ });
+
+ // Load local tasks.
+ grunt.loadTasks('tasks');
+
+ // Default task.
+ grunt.registerTask('default', 'lint test');
+
+};
35 package.json
@@ -0,0 +1,35 @@
+{
+ "name": "grunt-wrap",
+ "description": "A Grunt plugin for wrapping project text files",
+ "version": "0.1.0",
+ "homepage": "https://github.com/chrissrogers/grunt-wrap",
+ "author": {
+ "name": "Christopher Rogers"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/chrissrogers/grunt-move.git"
+ },
+ "bugs": {
+ "url": "https://github.com/chrissrogers/grunt-move/issues"
+ },
+ "licenses": [{
+ "type": "MIT",
+ "url": "https://github.com/chrissrogers/grunt-move/blob/master/LICENSE-MIT"
+ }],
+ "main": "grunt.js",
+ "bin": "bin/grunt-move",
+ "engines": {
+ "node": "*"
+ },
+ "scripts": {
+ "test": "grunt test"
+ },
+ "dependencies": {
+ "grunt": "~0.3.8"
+ },
+ "devDependencies": {
+ "grunt": "~0.3.8"
+ },
+ "keywords": ["gruntplugin"]
+}
55 tasks/grunt-cp.js
@@ -0,0 +1,55 @@
+/**
+ * grunt-wrap
+ * https://github.com/chrissrogers/grunt-wrap
+ *
+ * Copyright (c) 2012 Christopher Rogers
+ * Licensed under the MIT license.
+ */
+
+// wrap: {
+// modules: {
+// src: ['assets/*.js'],
+// dest: 'dist/',
+// wrapper: ['define(function (require, exports, module) {\n', '\n});']
+// }
+// }
+
+module.exports = function(grunt) {
+
+ // ==========================================================================
+ // TASKS
+ // ==========================================================================
+
+ grunt.registerMultiTask('wrap', 'Wrap files.', function () {
+ var files = grunt.file.expandFiles(this.file.src),
+ path = require('path'),
+ task = this,
+ src;
+
+ // Concat specified files.
+ if (files) {
+ files.map(function (filepath) {
+ src = grunt.helper('wrap', filepath, {wrapper: task.data.wrapper});
+ grunt.file.write(path.join(task.file.dest, filepath), src);
+ });
+ }
+
+ // Fail task if errors were logged.
+ if (this.errorCount) return false;
+
+ // Otherwise, print a success message.
+ grunt.log.writeln('Wrapped files created in "' + this.file.dest + '".');
+ });
+
+ // ==========================================================================
+ // HELPERS
+ // ==========================================================================
+
+ grunt.registerHelper('wrap', function (filepath, options) {
+ options = grunt.utils._.defaults(options || {}, {
+ wrapper: ['', '']
+ });
+ return options.wrapper[0] + grunt.task.directive(filepath, grunt.file.read) + options.wrapper[1];
+ });
+
+};
34 test/gruntplugin-example_test.js
@@ -0,0 +1,34 @@
+var grunt = require('grunt');
+
+/*
+ ======== A Handy Little Nodeunit Reference ========
+ https://github.com/caolan/nodeunit
+
+ Test methods:
+ test.expect(numAssertions)
+ test.done()
+ Test assertions:
+ test.ok(value, [message])
+ test.equal(actual, expected, [message])
+ test.notEqual(actual, expected, [message])
+ test.deepEqual(actual, expected, [message])
+ test.notDeepEqual(actual, expected, [message])
+ test.strictEqual(actual, expected, [message])
+ test.notStrictEqual(actual, expected, [message])
+ test.throws(block, [error], [message])
+ test.doesNotThrow(block, [error], [message])
+ test.ifError(value)
+*/
+
+exports['gruntplugin-example'] = {
+ setUp: function(done) {
+ // setup here
+ done();
+ },
+ 'helper': function(test) {
+ test.expect(1);
+ // tests here
+ test.equal(grunt.helper('gruntplugin-example'), 'gruntplugin-example!!!', 'should return the correct value.');
+ test.done();
+ }
+};
Please sign in to comment.
Something went wrong with that request. Please try again.