Permalink
Browse files

updates dependency versions. adds options documentation to readme. cl…

…eans up gruntfile, and

adds bower.json/.bowerrc to make it easier to pull down test files.
  • Loading branch information...
jonschlinkert committed Dec 15, 2013
1 parent 4530a42 commit 703e27e3c2f16b0096c5775eb47d02a6547d59fc
Showing with 87 additions and 112 deletions.
  1. +3 −0 .bowerrc
  2. +10 −25 Gruntfile.js
  3. +52 −29 README.md
  4. +9 −0 bower.json
  5. +4 −6 package.json
  6. +9 −4 tasks/js2coffee.js
  7. +0 −48 test/js2coffee_test.js
View
@@ -0,0 +1,3 @@
+{
+ "directory": "tmp"
+}
View
@@ -14,11 +14,7 @@ module.exports = function(grunt) {
grunt.initConfig({
jshint: {
- all: [
- 'Gruntfile.js',
- 'tasks/*.js',
- '<%= nodeunit.tests %>'
- ],
+ all: ['Gruntfile.js', 'tasks/*.js'],
options: {
jshintrc: '.jshintrc'
}
@@ -27,35 +23,25 @@ module.exports = function(grunt) {
// Configuration to be run (and then tested).
js2coffee: {
single: {
- files: {
- 'tmp/actual/single/contains.coffee': [
- 'test/fixtures/mout/string/contains.js'
- ]
- }
+ options: {
+ single_quotes: false,
+ indent: ' ',
+ show_src_lineno: true
+ },
+ src: 'tmp/mout/src/string/contains.js',
+ dest: 'tmp/single/contains.coffee'
},
each: {
- options: {},
files: [
- {
- expand: true,
- cwd: 'test/fixtures/mout',
- src: ['**/*.js'],
- dest: 'tmp/actual/',
- ext: '.coffee'
- }
+ {expand: true, cwd: 'tmp/mout/src', src: ['**/*.js'], dest: 'tmp/coffee/mout/', ext: '.coffee'}
]
}
},
- // Unit tests.
- nodeunit: {
- tests: ['test/*_test.js']
- },
-
// Before generating any new files,
// remove any previously-created files.
clean: {
- tests: ['tmp/actual/mout/**']
+ tests: ['tmp/coffee/**', 'tmp/single/**']
}
});
@@ -65,7 +51,6 @@ module.exports = function(grunt) {
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
- grunt.loadNpmTasks('grunt-contrib-nodeunit');
// plugin's task(s), then test the result.
grunt.registerTask('test', ['clean', 'js2coffee']);
View
@@ -19,43 +19,62 @@ grunt.loadNpmTasks('js2coffee');
If the plugin has been installed correctly, running `grunt --help` at the command line should list the newly-installed plugin's task or tasks. In addition, the plugin should be listed in package.json as a `devDependency`, which ensures that it will be installed whenever the `npm install` command is run.
-[grunt]: http://gruntjs.com/
-[Getting Started]: https://github.com/gruntjs/grunt/blob/devel/docs/getting_started.md
-[package.json]: https://npmjs.org/doc/json.html
## The "js2coffee" task
-### Overview
+### Options
+
+#### no_comments
+Type: `Boolean`
+Default: `False` (comments are translated by default)
+
+Ignore (do not translate) comments, if true.
+
+#### show_src_lineno
+Type: `Boolean`
+Default: `False`
+
+Show source line numbers in each line as comment, if true.
+
+#### indent
+Type: `String`
+Default: ` ` (two spaces)
+
+Specify indent.
+
+#### single_quotes
+Type: `Boolean`
+Default: `"` (double quoted)
+
+Use single quoted string literals instead of double quoted.
+
+
+### Usage examples
In your project's Gruntfile, add a section named `js2coffee` to the data object passed into `grunt.initConfig()`.
```js
grunt.initConfig({
js2coffee: {
- your_target: {
- // Target-specific file lists and/or options go here.
- }
- // Example: this target compiles a single file
- // from JavaScript to CofeeScript
+ options: {
+ // Task-level options go here
+ },
+ // Example: this target compiles a single file from JavaScript to CofeeScript
single: {
- files: {
- 'test/result/single/ltrim.coffee': [
- 'test/fixtures/mout/string/ltrim.js'
- ]
- }
+ src: 'tmp/mout/src/string/contains.js',
+ dest: 'tmp/single/contains.coffee'
},
- // Example: this target compiles a directory of
- // JavaScript files to individual CofeeScript
- // files, retaining the same directory structure
+ // Example: this target compiles a directory of JavaScript files to
+ // individual CofeeScript files, retaining the same directory structure
// in the destination folder
each: {
options: {},
files: [
- {
- expand: true,
- cwd: 'test/fixtures/mout',
- src: ['**/*.js'],
- dest: 'test/result/each/mout',
+ {
+ expand: true,
+ cwd: 'tmp/mout/src',
+ src: ['**/*.js'],
+ dest: 'tmp/coffee/',
ext: '.coffee'
}
]
@@ -68,17 +87,21 @@ grunt.initConfig({
## 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][].
-## Credit
-
-Thank you to **[@rstacruz](https://github.com/rstacruz)** and the contributors of [js2coffee](https://github.com/rstacruz/js2coffee) for all of the hard work that made this plugin possible.
-
-## Plugin Author
+## Author
**Jon Schlinkert**
+ [http://twitter.com/jonschlinkert](http://twitter.com/jonschlinkert)
+ [http://github.com/jonschlinkert](http://github.com/jonschlinkert)
+## Credit
-## Release History
-* 2013-05-12 v0.1.0 First commit.
+Thank you to **[@rstacruz](https://github.com/rstacruz)** and the contributors of [js2coffee](https://github.com/rstacruz/js2coffee) for all of the hard work that made this plugin possible.
+
+## License
+Copyright (c) 2013 Jon Schlinkert, contributors.
+Licensed under the MIT license.
+
+[grunt]: http://gruntjs.com/
+[Getting Started]: https://github.com/gruntjs/grunt/blob/devel/docs/getting_started.md
+[package.json]: https://npmjs.org/doc/json.html
View
@@ -0,0 +1,9 @@
+{
+ "name": "grunt-js2coffee",
+ "devDependencies": {
+ "mout": "~0.8.0"
+ },
+ "dependencies": {
+ "lodash": "~2.4.1"
+ }
+}
View
@@ -1,7 +1,7 @@
{
"name": "grunt-js2coffee",
"description": "Convert JavaScript to coffee-script.",
- "version": "0.2.0",
+ "version": "0.2.1",
"homepage": "https://github.com/jonschlinkert/grunt-js2coffee/",
"author": {
"name": "Jon Schlinkert",
@@ -28,14 +28,12 @@
"test": "grunt test"
},
"dependencies": {
- "js2coffee": "~0.2.2"
+ "js2coffee": "~0.2.3"
},
"devDependencies": {
- "grunt": "~0.4.1",
- "coffee-script": "~1.6.3",
+ "grunt": "~0.4.2",
"grunt-contrib-clean": "~0.5.0",
- "grunt-contrib-jshint": "~0.6.0",
- "grunt-contrib-nodeunit": "~0.2.0"
+ "grunt-contrib-jshint": "~0.7.2"
},
"keywords": [
"gruntplugin",
View
@@ -1,8 +1,8 @@
/*
* js2coffee
- * https://github.com/assemble/assemble-examples/
+ * https://github.com/jonschlinkert/grunt-js2coffee
*
- * Copyright (c) 2013 assemble
+ * Copyright (c) 2013 Jon Schlinkert
* Licensed under the MIT license.
*/
@@ -12,10 +12,15 @@ module.exports = function(grunt) {
var path = require('path');
- grunt.registerMultiTask('js2coffee', 'Your task description goes here.', function() {
+ grunt.registerMultiTask('js2coffee', 'Convert JavaScript files to CoffeeScript.', function() {
// Merge task-specific and/or target-specific options with these defaults.
- var options = this.options({});
+ var options = this.options({
+ single_quotes: true,
+ indent: ' ',
+ no_comments: false,
+ show_src_lineno: false
+ });
// Iterate over all specified file groups.
this.files.forEach(function(fp) {
View
@@ -1,48 +0,0 @@
-'use strict';
-
-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.js2coffee = {
- setUp: function(done) {
- // setup here if necessary
- done();
- },
- default_options: function(test) {
- test.expect(1);
-
- var actual = grunt.file.read('tmp/actual/default_options');
- var expected = grunt.file.read('test/expected/default_options');
- test.equal(actual, expected, 'should describe what the default behavior is.');
-
- test.done();
- },
- custom_options: function(test) {
- test.expect(1);
-
- var actual = grunt.file.read('tmp/actual/custom_options');
- var expected = grunt.file.read('test/expected/custom_options');
- test.equal(actual, expected, 'should describe what the custom option(s) behavior is.');
-
- test.done();
- },
-};

0 comments on commit 703e27e

Please sign in to comment.