├── .gitattributes ├── .gitignore ├── .jshintrc ├── .npmignore ├── .travis.yml ├── AUTHORS ├── CHANGELOG ├── CONTRIBUTING.md ├── Gruntfile.js ├── LICENSE-MIT ├── README.md ├── docs ├── coffee-examples.md ├── coffee-options.md ├── coffee-overview.md └── overview.md ├── package.json ├── tasks └── coffee-react.js ├── test ├── coffee_test.js ├── expected │ ├── bare │ │ ├── coffee.js │ │ ├── concat.js │ │ └── litcoffee.js │ ├── default │ │ ├── coffee.js │ │ ├── concat.js │ │ └── litcoffee.js │ ├── eachMap │ │ ├── coffee1.js │ │ ├── coffee1.js.map │ │ ├── litcoffee.js │ │ └── litcoffee.js.map │ ├── join │ │ ├── bareJoin.js │ │ └── join.js │ ├── maps │ │ ├── coffee.js │ │ ├── coffee.js.map │ │ ├── coffeeBare.js │ │ ├── coffeeBare.js.map │ │ ├── coffeeBareJoin.js │ │ ├── coffeeBareJoin.js.map │ │ ├── coffeeBareJoin.src.coffee │ │ ├── coffeeJoin.js │ │ ├── coffeeJoin.js.map │ │ ├── coffeeJoin.src.coffee │ │ └── coffeeNested.js.map │ ├── react │ │ └── coffee-react.js │ ├── sourceMapDir1 │ │ └── coffee.js │ └── sourceMapDir2 │ │ └── coffee.js.map └── fixtures │ ├── coffee-react.cjsx │ ├── coffee1.coffee │ ├── coffee2.coffee │ ├── litcoffee.coffee.md │ └── litcoffee.litcoffee └── update.sh /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | tmp -------------------------------------------------------------------------------- /.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 | } 14 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | src/ 2 | test/ 3 | examples/ 4 | Cakefile 5 | *.sh -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.10" 4 | before_install: 5 | - npm install -g npm 6 | before_script: 7 | - npm install -g grunt-cli 8 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Eric Woroshow (http://ericw.ca/) 2 | Tyler Kellen (http://goingslowly.com/) 3 | Chris Talkington (http://christalkington.com/) 4 | Kyle Robinson Young (http://twitter.com/shamakry) 5 | Yegor Pomortsev (https://github.com/illicium) 6 | Sindre Sorhus (http://github.com/sindresorhus) 7 | Callum Locke (https://github.com/callumlocke) 8 | Scott Delamater (https://github.com/scottydawg) 9 | Colin Wren (http://cawren.com) 10 | Johnny Freeman (https://twitter.com/prsjohnny) 11 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | v0.10.0: 2 | date: 2014-02-07 3 | changes: 4 | - SourceMappingURL calculated correctly 5 | v0.9.0: 6 | date: 2014-01-29 7 | changes: 8 | - Source mapping fixes. 9 | - Update coffee-script to 1.7.0 10 | - Use lodash directly instead of deprecated grunt.util._ 11 | v0.8.2: 12 | date: 2014-01-17 13 | changes: 14 | - Force coffeescript 1.6.3 15 | - Use new sourceMappingUrl syntax. 16 | v0.8.1: 17 | date: 2014-01-17 18 | changes: 19 | - Fix sourcemap regression. 20 | v0.8.0: 21 | date: 2013-12-24 22 | changes: 23 | - Support sourceMapDir 24 | v0.7.0: 25 | date: 2013-04-19 26 | changes: 27 | - Place Sourcemaps at bottom of file 28 | - Change extension for Sourcemaps from .maps to .js.map 29 | v0.6.7: 30 | date: 2013-04-18 31 | changes: 32 | - Improved error reporting 33 | v0.6.6: 34 | date: 2013-04-08 35 | changes: 36 | - Fix regression with single-file compilation. 37 | v0.6.5: 38 | date: 2013-04-05 39 | changes: 40 | - Improved error reporting 41 | v0.6.4: 42 | date: 2013-03-22 43 | changes: 44 | - Sourcemap support 45 | v0.6.3: 46 | date: 2013-03-19 47 | changes: 48 | - Increase error logging verbosity. 49 | v0.6.2: 50 | date: 2013-03-18 51 | changes: 52 | - Bump to CoffeeScript 1.6.2 53 | v0.6.1: 54 | date: 2013-03-18 55 | changes: 56 | - Support `join` option 57 | v0.6.0: 58 | date: 2013-03-06 59 | changes: 60 | - Bump to CoffeeScript 1.6 61 | - Support literate CoffeeScript extension coffee.md 62 | v0.5.0: 63 | date: 2013-02-25 64 | changes: 65 | - Bump to CoffeeScript 1.5 66 | - Support literate CoffeeScript (.litcoffee) 67 | v0.4.0: 68 | date: 2013-02-15 69 | changes: 70 | - First official release for Grunt 0.4.0. 71 | v0.4.0rc7: 72 | date: 2013-01-23 73 | changes: 74 | - Updating grunt/gruntplugin dependencies to rc7. 75 | - Changing in-development grunt/gruntplugin dependency versions from tilde version ranges to specific versions. 76 | - Bump coffeescript dependency to 1.4. 77 | v0.4.0rc5: 78 | date: 2013-01-09 79 | changes: 80 | - Updating to work with grunt v0.4.0rc5. 81 | - Switching to this.filesSrc api. 82 | v0.4.0a: 83 | date: 2012-12-15 84 | changes: 85 | - Conversion to grunt v0.4 conventions. 86 | - Remove experimental destination wildcards. 87 | v0.3.2: 88 | date: 2012-10-12 89 | changes: 90 | - Rename grunt-contrib-lib dep to grunt-lib-contrib. 91 | v0.3.1: 92 | date: 2012-09-25 93 | changes: 94 | - Don't fail when there are no files. 95 | v0.3.0: 96 | date: 2012-09-24 97 | changes: 98 | - Global options depreciated. 99 | v0.2.0: 100 | date: 2012-09-10 101 | changes: 102 | - Refactored from grunt-contrib into individual repo. 103 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Please see the [Contributing to grunt](http://gruntjs.com/contributing) guide for information on contributing to this project. 2 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | /* 2 | * grunt-contrib-coffee 3 | * http://gruntjs.com/ 4 | * 5 | * Copyright (c) 2014 Eric Woroshow, contributors 6 | * Licensed under the MIT license. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | module.exports = function(grunt) { 12 | 13 | var mixedConcatFixtures = [ 14 | 'test/fixtures/coffee1.coffee', 15 | 'test/fixtures/coffee2.coffee', 16 | 'test/fixtures/litcoffee.litcoffee' 17 | ]; 18 | 19 | var uniformConcatFixtures = [ 20 | 'test/fixtures/coffee1.coffee', 21 | 'test/fixtures/coffee2.coffee' 22 | ]; 23 | 24 | // Project configuration. 25 | grunt.initConfig({ 26 | jshint: { 27 | all: [ 28 | 'Gruntfile.js', 29 | 'tasks/*.js', 30 | '<%= nodeunit.tests %>' 31 | ], 32 | options: { 33 | jshintrc: '.jshintrc' 34 | } 35 | }, 36 | 37 | // Before generating any new files, remove any previously-created files. 38 | clean: { 39 | tests: ['tmp/bare', 'tmp/default', 'tmp/join', 'tmp/sourceMapDir1', 'tmp/sourceMapDir2', 'tmp/nest'] 40 | }, 41 | 42 | // Configuration to be run (and then tested). 43 | cjsx: { 44 | compileReact: { 45 | files: { 46 | 'tmp/react/coffee-react.js': ['test/fixtures/coffee-react.cjsx'], 47 | } 48 | }, 49 | compileDefault: { 50 | files: { 51 | 'tmp/default/coffee.js': ['test/fixtures/coffee1.coffee'], 52 | 'tmp/default/litcoffee.js': ['test/fixtures/litcoffee.litcoffee'], 53 | 'tmp/default/litcoffeemd.js': ['test/fixtures/litcoffee.coffee.md'], 54 | 'tmp/default/concat.js': mixedConcatFixtures 55 | } 56 | }, 57 | compileBare: { 58 | options: { 59 | bare: true 60 | }, 61 | files: { 62 | 'tmp/bare/coffee.js': ['test/fixtures/coffee1.coffee'], 63 | 'tmp/bare/litcoffee.js': ['test/fixtures/litcoffee.litcoffee'], 64 | 'tmp/bare/litcoffeemd.js': ['test/fixtures/litcoffee.coffee.md'], 65 | 'tmp/bare/concat.js': mixedConcatFixtures 66 | } 67 | }, 68 | compileJoined: { 69 | options: { 70 | join: true 71 | }, 72 | files: { 73 | 'tmp/join/coffee.js': ['test/fixtures/coffee1.coffee'], 74 | 'tmp/join/join.js': uniformConcatFixtures 75 | } 76 | }, 77 | compileBareJoined: { 78 | options: { 79 | bare: true, 80 | join: true 81 | }, 82 | files: { 83 | 'tmp/join/bareCoffee.js': ['test/fixtures/coffee1.coffee'], 84 | 'tmp/join/bareJoin.js': uniformConcatFixtures 85 | } 86 | }, 87 | compileMaps: { 88 | options: { 89 | sourceMap: true 90 | }, 91 | files: { 92 | 'tmp/maps/coffee.js': ['test/fixtures/coffee1.coffee'], 93 | 'tmp/maps/coffeeJoin.js': uniformConcatFixtures 94 | } 95 | }, 96 | compileSourceMapDir: { 97 | options: { 98 | sourceMap: true, 99 | sourceMapDir: 'tmp/sourceMapDir2' 100 | }, 101 | files: { 102 | 'tmp/sourceMapDir1/coffee.js': ['test/fixtures/coffee1.coffee'] 103 | } 104 | }, 105 | compileEachMap: { 106 | options: { 107 | sourceMap: true 108 | }, 109 | files: [{ 110 | expand: true, 111 | cwd: 'test/fixtures/', 112 | src: ['coffee1.coffee', 'litcoffee.litcoffee'], 113 | dest: 'tmp/eachMap/', 114 | ext: '.js' 115 | }] 116 | }, 117 | compileBareMaps: { 118 | options: { 119 | sourceMap: true, 120 | bare: true 121 | }, 122 | files: { 123 | 'tmp/maps/coffeeBare.js': ['test/fixtures/coffee1.coffee'], 124 | 'tmp/maps/coffeeBareJoin.js': uniformConcatFixtures 125 | } 126 | }, 127 | compileNested: { 128 | options: { 129 | sourceMap: true 130 | }, 131 | files: { 132 | 'tmp/nest/1/coffee.js': ['test/fixtures/coffee1.coffee'], 133 | 'tmp/nest/2/coffee.js': ['test/fixtures/coffee1.coffee'] 134 | } 135 | } 136 | }, 137 | 138 | // Unit tests. 139 | nodeunit: { 140 | tests: ['test/*_test.js'] 141 | } 142 | }); 143 | 144 | // Actually load this plugin's task(s). 145 | grunt.loadTasks('tasks'); 146 | 147 | // These plugins provide necessary tasks. 148 | grunt.loadNpmTasks('grunt-contrib-jshint'); 149 | grunt.loadNpmTasks('grunt-contrib-clean'); 150 | grunt.loadNpmTasks('grunt-contrib-nodeunit'); 151 | grunt.loadNpmTasks('grunt-contrib-internal'); 152 | 153 | // Whenever the "test" task is run, first clean the "tmp" dir, then run this 154 | // plugin's task(s), then test the result. 155 | grunt.registerTask('test', ['clean', 'cjsx', 'nodeunit']); 156 | 157 | // By default, lint and run all tests. 158 | grunt.registerTask('default', ['jshint', 'test', 'build-contrib']); 159 | 160 | }; 161 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Eric Woroshow, contributors 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. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # grunt-coffee-react 2 | Compile [coffee-react-transform](https://github.com/jsdf/coffee-react-transform) CJSX files to JavaScript. 3 | 4 | ## Getting Started 5 | This plugin requires Grunt `>=0.4.0` 6 | 7 | For version compatibility with React, see [coffee-react version compatibility](https://github.com/jsdf/coffee-react#version-compatibility) 8 | 9 | **note** 10 | 11 | ```shell 12 | npm install grunt-coffee-react --save-dev 13 | ``` 14 | 15 | Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript: 16 | 17 | ```js 18 | grunt.loadNpmTasks('grunt-coffee-react'); 19 | ``` 20 | 21 | ## 'cjsx' task 22 | _Run this task with the `grunt cjsx` command._ 23 | 24 | Task targets, files and options may be specified according to the grunt [Configuring tasks](http://gruntjs.com/configuring-tasks) guide. 25 | ### Options 26 | 27 | #### separator 28 | Type: `String` 29 | Default: linefeed 30 | 31 | Concatenated files will be joined on this string. 32 | 33 | #### bare 34 | Type: `boolean` 35 | 36 | Compile the JavaScript without the top-level function safety wrapper. 37 | 38 | #### join 39 | Type: `boolean` 40 | Default: `false` 41 | 42 | When compiling multiple CJSX files into a single .js file, concatenate first. 43 | 44 | #### sourceMap 45 | Type: `boolean` 46 | Default: `false` 47 | 48 | Compile JavaScript and create a .map file linking it to the CJSX source. When compiling multiple .coffee files to a single .js file, concatenation occurs as though the 'join' option is enabled 49 | 50 | #### sourceMapDir 51 | Type: `String` 52 | Default: (same path as your compiled js files) 53 | 54 | Generated source map files will be created here. 55 | 56 | #### joinExt 57 | Type: `String` 58 | Default: '.src.coffee' 59 | 60 | Resulting extension when joining multiple CJSX files. 61 | 62 | ### Usage Examples 63 | 64 | ```js 65 | cjsx: { 66 | compile: { 67 | files: { 68 | 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile 69 | 'path/to/another.js': ['path/to/sources/*.cjsx', 'path/to/more/*.coffee'] // compile and concat into single file 70 | } 71 | }, 72 | 73 | compileBare: { 74 | options: { 75 | bare: true 76 | }, 77 | files: { 78 | 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile 79 | 'path/to/another.js': ['path/to/sources/*.cjsx', 'path/to/more/*.coffee'] // compile and concat into single file 80 | } 81 | }, 82 | 83 | compileJoined: { 84 | options: { 85 | join: true 86 | }, 87 | files: { 88 | 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile, identical output to join = false 89 | 'path/to/another.js': ['path/to/sources/*.cjsx', 'path/to/more/*.coffee'] // concat then compile into single file 90 | } 91 | }, 92 | 93 | compileWithMaps: { 94 | options: { 95 | sourceMap: true 96 | }, 97 | files: { 98 | 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile 99 | 'path/to/another.js': ['path/to/sources/*.cjsx', 'path/to/more/*.coffee'] // concat then compile into single file 100 | } 101 | }, 102 | 103 | compileWithMapsDir: { 104 | options: { 105 | sourceMap: true, 106 | sourceMapDir: 'path/to/maps/' // source map files will be created here 107 | }, 108 | files: { 109 | 'path/to/result.js': 'path/to/source.coffee' 110 | } 111 | }, 112 | 113 | glob_to_multiple: { 114 | expand: true, 115 | flatten: true, 116 | cwd: 'path/to', 117 | src: ['*.coffee'], 118 | dest: 'path/to/dest/', 119 | ext: '.js' 120 | } 121 | 122 | } 123 | ``` 124 | 125 | For more examples on how to use the `expand` API to manipulate the default dynamic path construction in the `glob_to_multiple` examples, see "[Building the files object dynamically](http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically)" in the grunt wiki entry [Configuring Tasks](http://gruntjs.com/configuring-tasks). 126 | 127 | -------------------------------------------------------------------------------- /docs/coffee-examples.md: -------------------------------------------------------------------------------- 1 | # Usage Examples 2 | 3 | ```js 4 | coffee: { 5 | compile: { 6 | files: { 7 | 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile 8 | 'path/to/another.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // compile and concat into single file 9 | } 10 | }, 11 | 12 | compileBare: { 13 | options: { 14 | bare: true 15 | }, 16 | files: { 17 | 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile 18 | 'path/to/another.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // compile and concat into single file 19 | } 20 | }, 21 | 22 | compileJoined: { 23 | options: { 24 | join: true 25 | }, 26 | files: { 27 | 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile, identical output to join = false 28 | 'path/to/another.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // concat then compile into single file 29 | } 30 | }, 31 | 32 | compileWithMaps: { 33 | options: { 34 | sourceMap: true 35 | }, 36 | files: { 37 | 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile 38 | 'path/to/another.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // concat then compile into single file 39 | } 40 | }, 41 | 42 | compileWithMapsDir: { 43 | options: { 44 | sourceMap: true, 45 | sourceMapDir: 'path/to/maps/' // source map files will be created here 46 | }, 47 | files: { 48 | 'path/to/result.js': 'path/to/source.coffee' 49 | } 50 | } 51 | 52 | glob_to_multiple: { 53 | expand: true, 54 | flatten: true, 55 | cwd: 'path/to', 56 | src: ['*.coffee'], 57 | dest: 'path/to/dest/', 58 | ext: '.js' 59 | }, 60 | 61 | } 62 | ``` 63 | 64 | For more examples on how to use the `expand` API to manipulate the default dynamic path construction in the `glob_to_multiple` examples, see "[Building the files object dynamically](http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically)" in the grunt wiki entry [Configuring Tasks](http://gruntjs.com/configuring-tasks). 65 | -------------------------------------------------------------------------------- /docs/coffee-options.md: -------------------------------------------------------------------------------- 1 | # Options 2 | 3 | ## separator 4 | Type: `String` 5 | Default: linefeed 6 | 7 | Concatenated files will be joined on this string. 8 | 9 | ## bare 10 | Type: `boolean` 11 | 12 | Compile the JavaScript without the top-level function safety wrapper. 13 | 14 | ## join 15 | Type: `boolean` 16 | Default: `false` 17 | 18 | When compiling multiple .coffee files into a single .js file, concatenate first. 19 | 20 | ## sourceMap 21 | Type: `boolean` 22 | Default: `false` 23 | 24 | Compile JavaScript and create a .map file linking it to the CoffeeScript source. When compiling multiple .coffee files to a single .js file, concatenation occurs as though the 'join' option is enabled 25 | 26 | ## sourceMapDir 27 | Type: `String` 28 | Default: (same path as your compiled js files) 29 | 30 | Generated source map files will be created here. 31 | 32 | ## joinExt 33 | Type: `String` 34 | Default: '.src.coffee' 35 | 36 | Resulting extension when joining multiple CoffeeScript files. 37 | -------------------------------------------------------------------------------- /docs/coffee-overview.md: -------------------------------------------------------------------------------- 1 | Task targets, files and options may be specified according to the grunt [Configuring tasks](http://gruntjs.com/configuring-tasks) guide. -------------------------------------------------------------------------------- /docs/overview.md: -------------------------------------------------------------------------------- 1 | *This plugin was designed to work with Grunt 0.4.x. If you're still using grunt v0.3.x it's strongly recommended that [you upgrade](http://gruntjs.com/upgrading-from-0.3-to-0.4), but in case you can't please use [v0.3.2](https://github.com/gruntjs/grunt-contrib-coffee/tree/grunt-0.3-stable).* -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "grunt-coffee-react", 3 | "description": "Compile CJSX files to JavaScript.", 4 | "version": "5.0.0", 5 | "homepage": "https://github.com/jsdf/grunt-coffee-react", 6 | "author": { 7 | "name": "James Friend", 8 | "url": "https://github.com/jsdf" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git://github.com/jsdf/grunt-coffee-react.git" 13 | }, 14 | "bugs": { 15 | "url": "https://github.com/jsdf/grunt-coffee-react/issues" 16 | }, 17 | "licenses": [ 18 | { 19 | "type": "MIT", 20 | "url": "https://github.com/jsdf/grunt-coffee-react/blob/master/LICENSE-MIT" 21 | } 22 | ], 23 | "engines": { 24 | "node": ">= 0.8.0" 25 | }, 26 | "scripts": { 27 | "test": "grunt test" 28 | }, 29 | "dependencies": { 30 | "chalk": "~0.4.0", 31 | "coffee-react": "^5.0.0", 32 | "lodash": "~2.4.1" 33 | }, 34 | "devDependencies": { 35 | "grunt-contrib-jshint": "~0.6.4", 36 | "grunt-contrib-nodeunit": "~0.2.1", 37 | "grunt-contrib-clean": "~0.5.0", 38 | "grunt-contrib-internal": "~0.4.6", 39 | "grunt": "~0.4.1" 40 | }, 41 | "peerDependencies": { 42 | "grunt": ">=0.4.0" 43 | }, 44 | "keywords": [ 45 | "gruntplugin" 46 | ], 47 | "files": [ 48 | "tasks", 49 | "LICENSE-MIT" 50 | ] 51 | } 52 | -------------------------------------------------------------------------------- /tasks/coffee-react.js: -------------------------------------------------------------------------------- 1 | /* 2 | * grunt-contrib-coffee 3 | * http://gruntjs.com/ 4 | * 5 | * Copyright (c) 2014 Eric Woroshow, contributors 6 | * Licensed under the MIT license. 7 | */ 8 | 9 | 'use strict'; 10 | 11 | module.exports = function(grunt) { 12 | var path = require('path'); 13 | var chalk = require('chalk'); 14 | var _ = require('lodash'); 15 | 16 | grunt.registerMultiTask('cjsx', 'Compile CJSX files into JavaScript', function() { 17 | var options = this.options({ 18 | bare: false, 19 | join: false, 20 | sourceMap: false, 21 | joinExt: '.src.coffee', 22 | separator: grunt.util.linefeed 23 | }); 24 | 25 | options.separator = grunt.util.normalizelf(options.separator); 26 | 27 | this.files.forEach(function(f) { 28 | var validFiles = removeInvalidFiles(f); 29 | 30 | if (options.sourceMap === true) { 31 | var paths = createOutputPaths(f.dest); 32 | // add sourceMapDir to options object 33 | var fileOptions = _.extend({ sourceMapDir: paths.destDir }, options); 34 | writeFileAndMap(paths, compileWithMaps(validFiles, fileOptions, paths), fileOptions); 35 | } else if (options.join === true) { 36 | writeCompiledFile(f.dest, concatInput(validFiles, options)); 37 | } else { 38 | writeCompiledFile(f.dest, concatOutput(validFiles, options)); 39 | } 40 | }); 41 | }); 42 | 43 | var isLiterate = function(ext) { 44 | return (ext === ".litcoffee" || ext === ".md"); 45 | }; 46 | 47 | var removeInvalidFiles = function(files) { 48 | return files.src.filter(function(filepath) { 49 | if (!grunt.file.exists(filepath)) { 50 | grunt.log.warn('Source file "' + filepath + '" not found.'); 51 | return false; 52 | } else { 53 | return true; 54 | } 55 | }); 56 | }; 57 | 58 | var createOutputPaths = function(destination) { 59 | var fileName = path.basename(destination, path.extname(destination)); 60 | return { 61 | dest: destination, 62 | destName: fileName, 63 | destDir: appendTrailingSlash(path.dirname(destination)), 64 | mapFileName: fileName + '.js.map' 65 | }; 66 | }; 67 | 68 | var appendTrailingSlash = function(dirname) { 69 | if (dirname.length > 0 && dirname.slice(-1) !== path.sep) { 70 | return dirname + path.sep; 71 | } else { 72 | return dirname; 73 | } 74 | }; 75 | 76 | var compileWithMaps = function(files, options, paths) { 77 | if (!hasUniformExtensions(files)) { 78 | return; 79 | } 80 | 81 | var mapOptions, filepath; 82 | 83 | if (files.length > 1) { 84 | mapOptions = createOptionsForJoin(files, paths, options.separator, options.joinExt); 85 | } else { 86 | mapOptions = createOptionsForFile(files[0], paths); 87 | filepath = files[0]; 88 | } 89 | 90 | options = _.extend({ 91 | generatedFile: path.basename(paths.dest), 92 | sourceRoot: mapOptions.sourceRoot, 93 | sourceFiles: mapOptions.sourceFiles 94 | }, options); 95 | 96 | var output = compileCoffee(mapOptions.code, options, filepath); 97 | appendFooter(output, paths, options); 98 | return output; 99 | }; 100 | 101 | var hasUniformExtensions = function(files) { 102 | // get all extensions for input files 103 | var extensions = _.uniq(files.map(path.extname)); 104 | 105 | if (extensions.length > 1) { 106 | grunt.fail.warn('Join and sourceMap options require input files share the same extension (found ' + extensions.join(', ') + ').'); 107 | return false; 108 | } else { 109 | return true; 110 | } 111 | }; 112 | 113 | var createOptionsForJoin = function (files, paths, separator, joinExt) { 114 | var code = concatFiles(files, separator); 115 | var targetFileName = paths.destName + joinExt; 116 | grunt.file.write(paths.destDir + targetFileName, code); 117 | 118 | return { 119 | code: code, 120 | sourceFiles: [targetFileName], 121 | sourceRoot: '' 122 | }; 123 | }; 124 | 125 | var concatFiles = function(files, separator) { 126 | return files.map(grunt.file.read).join(separator); 127 | }; 128 | 129 | var createOptionsForFile = function(file, paths) { 130 | return { 131 | code: grunt.file.read(file), 132 | sourceFiles: [path.basename(file)], 133 | sourceRoot: appendTrailingSlash(path.relative(paths.destDir, path.dirname(file))) 134 | }; 135 | }; 136 | 137 | var appendFooter = function(output, paths, options) { 138 | // We need the sourceMappingURL to be relative to the JS path 139 | var sourceMappingDir = appendTrailingSlash(path.relative(paths.destDir, options.sourceMapDir)); 140 | // Add sourceMappingURL to file footer 141 | output.js = output.js + '\n//# sourceMappingURL=' + sourceMappingDir + paths.mapFileName + '\n'; 142 | }; 143 | 144 | var concatInput = function(files, options) { 145 | if (hasUniformExtensions(files)) { 146 | var code = concatFiles(files, options.separator); 147 | return compileCoffee(code, options); 148 | } 149 | }; 150 | 151 | var concatOutput = function(files, options) { 152 | return files.map(function(filepath) { 153 | var code = grunt.file.read(filepath); 154 | return compileCoffee(code, options, filepath); 155 | }).join(options.separator); 156 | }; 157 | 158 | var compileCoffee = function(code, options, filepath) { 159 | var coffeeOptions = _.clone(options); 160 | if (filepath) { 161 | coffeeOptions.filename = filepath; 162 | coffeeOptions.literate = isLiterate(path.extname(filepath)); 163 | } 164 | 165 | try { 166 | return require('coffee-react').compile(code, coffeeOptions); 167 | } catch (e) { 168 | if (e.location == null || 169 | e.location.first_column == null || 170 | e.location.first_line == null) { 171 | grunt.log.error('Got an unexpected exception ' + 172 | 'from the coffee-script compiler. ' + 173 | 'The original exception was: ' + 174 | e); 175 | grunt.log.error('(The coffee-script compiler should not raise *unexpected* exceptions. ' + 176 | 'You can file this error as an issue of the coffee-script compiler: ' + 177 | 'https://github.com/jashkenas/coffee-script/issues)'); 178 | } else { 179 | var firstColumn = e.location.first_column; 180 | var firstLine = e.location.first_line; 181 | var codeLine = code.split('\n')[firstLine]; 182 | var errorArrows = chalk.red('>>') + ' '; 183 | var offendingCharacter; 184 | 185 | if (firstColumn < codeLine.length) { 186 | offendingCharacter = chalk.red(codeLine[firstColumn]); 187 | } else { 188 | offendingCharacter = ''; 189 | } 190 | 191 | grunt.log.error(e); 192 | grunt.log.error('In file: ' + filepath); 193 | grunt.log.error('On line: ' + firstLine); 194 | // log erroneous line and highlight offending character 195 | // grunt.log.error trims whitespace so we have to use grunt.log.writeln 196 | grunt.log.writeln(errorArrows + codeLine.substring(0, firstColumn) + 197 | offendingCharacter + codeLine.substring(firstColumn + 1)); 198 | grunt.log.writeln(errorArrows + grunt.util.repeat(firstColumn, ' ') + 199 | chalk.red('^')); 200 | } 201 | grunt.fail.warn('CoffeeScript failed to compile.'); 202 | } 203 | }; 204 | 205 | var writeFileAndMap = function(paths, output, options) { 206 | if (!output || output.js.length === 0) { 207 | warnOnEmptyFile(paths.dest); 208 | return; 209 | } 210 | 211 | writeCompiledFile(paths.dest, output.js); 212 | options.sourceMapDir = appendTrailingSlash(options.sourceMapDir); 213 | writeSourceMapFile(options.sourceMapDir + paths.mapFileName, output.v3SourceMap); 214 | }; 215 | 216 | var warnOnEmptyFile = function(path) { 217 | grunt.log.warn('Destination "' + path + '" not written because compiled files were empty.'); 218 | }; 219 | 220 | var writeFile = function(path, output) { 221 | if (output.length < 1) { 222 | warnOnEmptyFile(path); 223 | return false; 224 | } else { 225 | grunt.file.write(path, output); 226 | return true; 227 | } 228 | }; 229 | 230 | var writeCompiledFile = function(path, output) { 231 | if (writeFile(path, output)) { 232 | grunt.log.writeln('File ' + chalk.cyan(path) + ' created.'); 233 | } 234 | }; 235 | var writeSourceMapFile = function(path, output) { 236 | if (writeFile(path, output)) { 237 | grunt.log.writeln('File ' + chalk.cyan(path) + ' created (source map).'); 238 | } 239 | }; 240 | }; 241 | -------------------------------------------------------------------------------- /test/coffee_test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var grunt = require('grunt'); 4 | 5 | function readFile(file) { 6 | var contents = grunt.file.read(file); 7 | if (process.platform === 'win32') { 8 | contents = contents.replace(/\r\n/g, '\n'); 9 | } 10 | return contents; 11 | } 12 | 13 | function assertFileEquality(test, pathToActual, pathToExpected, message) { 14 | var actual = readFile(pathToActual); 15 | var expected = readFile(pathToExpected); 16 | test.equal(expected, actual, message); 17 | } 18 | 19 | exports.coffee = { 20 | compileBare: function(test) { 21 | test.expect(4); 22 | 23 | assertFileEquality(test, 24 | 'tmp/bare/coffee.js', 25 | 'test/expected/bare/coffee.js', 26 | 'Should compile coffeescript to unwrapped javascript'); 27 | 28 | assertFileEquality(test, 29 | 'tmp/bare/litcoffee.js', 30 | 'test/expected/bare/litcoffee.js', 31 | 'Should compile literate coffeescript to unwrapped javascript'); 32 | 33 | assertFileEquality(test, 34 | 'tmp/bare/litcoffeemd.js', 35 | 'test/expected/bare/litcoffee.js', 36 | 'Should compile literate coffeescript to unwrapped javascript'); 37 | 38 | assertFileEquality(test, 39 | 'tmp/bare/concat.js', 40 | 'test/expected/bare/concat.js', 41 | 'Should compile coffeescript files without wrappers and concatenate them into a single javascript file'); 42 | 43 | test.done(); 44 | }, 45 | compileDefault: function(test) { 46 | test.expect(4); 47 | 48 | assertFileEquality(test, 49 | 'tmp/default/coffee.js', 50 | 'test/expected/default/coffee.js', 51 | 'Should compile coffeescript to javascript'); 52 | 53 | assertFileEquality(test, 54 | 'tmp/default/litcoffee.js', 55 | 'test/expected/default/litcoffee.js', 56 | 'Should compile literate coffeescript to wrapped javascript'); 57 | 58 | assertFileEquality(test, 59 | 'tmp/default/litcoffeemd.js', 60 | 'test/expected/default/litcoffee.js', 61 | 'Should compile literate coffeescript to wrapped javascript'); 62 | 63 | assertFileEquality(test, 64 | 'tmp/default/concat.js', 65 | 'test/expected/default/concat.js', 66 | 'Should compile coffeescript files with wrappers and concatenate them into a single javascript file'); 67 | 68 | test.done(); 69 | }, 70 | compileReact: function(test) { 71 | test.expect(1); 72 | 73 | assertFileEquality(test, 74 | 'tmp/react/coffee-react.js', 75 | 'test/expected/react/coffee-react.js', 76 | 'Should compile CJSX to javascript'); 77 | 78 | test.done(); 79 | }, 80 | compileJoined: function(test) { 81 | test.expect(4); 82 | 83 | assertFileEquality(test, 84 | 'tmp/join/coffee.js', 85 | 'test/expected/default/coffee.js', 86 | 'Compilation of one file with join enabled should match normal compilation'); 87 | 88 | assertFileEquality(test, 89 | 'tmp/join/join.js', 90 | 'test/expected/join/join.js', 91 | 'Should concatenate coffeescript files prior to compilation into a single javascript file'); 92 | 93 | assertFileEquality(test, 94 | 'tmp/join/bareCoffee.js', 95 | 'test/expected/bare/coffee.js', 96 | 'Bare compilation of one file with join enabled should match bare compilation'); 97 | 98 | assertFileEquality(test, 99 | 'tmp/join/bareJoin.js', 100 | 'test/expected/join/bareJoin.js', 101 | 'Bare compilation of multiple join files should be equivalent to concatenated compilation'); 102 | 103 | test.done(); 104 | }, 105 | compileMaps: function(test) { 106 | test.expect(10); 107 | 108 | assertFileEquality(test, 109 | 'tmp/maps/coffee.js', 110 | 'test/expected/maps/coffee.js', 111 | 'Compilation of single file with source maps should generate javascript'); 112 | 113 | assertFileEquality(test, 114 | 'tmp/maps/coffee.js.map', 115 | 'test/expected/maps/coffee.js.map', 116 | 'Compilation of single file with source maps should generate map'); 117 | 118 | assertFileEquality(test, 119 | 'tmp/maps/coffeeJoin.js', 120 | 'test/expected/maps/coffeeJoin.js', 121 | 'Compilation of multiple files with source maps should generate javascript'); 122 | 123 | assertFileEquality(test, 124 | 'tmp/maps/coffeeJoin.js.map', 125 | 'test/expected/maps/coffeeJoin.js.map', 126 | 'Compilation of multiple files with source maps should generate map'); 127 | 128 | assertFileEquality(test, 129 | 'tmp/maps/coffeeJoin.src.coffee', 130 | 'test/expected/maps/coffeeJoin.src.coffee', 131 | 'Compilation of multiple files with source maps should output concatenated source'); 132 | 133 | assertFileEquality(test, 134 | 'tmp/maps/coffeeBare.js', 135 | 'test/expected/maps/coffeeBare.js', 136 | 'Bare compilation of single file with source maps should generate javascript'); 137 | 138 | assertFileEquality(test, 139 | 'tmp/maps/coffeeBare.js.map', 140 | 'test/expected/maps/coffeeBare.js.map', 141 | 'Bare compilation of single file with source maps should generate map'); 142 | 143 | assertFileEquality(test, 144 | 'tmp/maps/coffeeBareJoin.js', 145 | 'test/expected/maps/coffeeBareJoin.js', 146 | 'Bare compilation of multiple files with source maps should generate javascript'); 147 | 148 | assertFileEquality(test, 149 | 'tmp/maps/coffeeBareJoin.js.map', 150 | 'test/expected/maps/coffeeBareJoin.js.map', 151 | 'Bare compilation of multiple files with source maps should generate map'); 152 | 153 | assertFileEquality(test, 154 | 'tmp/maps/coffeeBareJoin.src.coffee', 155 | 'test/expected/maps/coffeeBareJoin.src.coffee', 156 | 'Bare compilation of multiple files with source maps should output concatenated source'); 157 | 158 | test.done(); 159 | }, 160 | compileEachMap: function(test) { 161 | test.expect(4); 162 | 163 | assertFileEquality(test, 164 | 'tmp/eachMap/coffee1.js', 165 | 'test/expected/eachMap/coffee1.js', 166 | 'Separate compilation of coffee and litcoffee files with source maps should generate javascript'); 167 | 168 | assertFileEquality(test, 169 | 'tmp/eachMap/litcoffee.js', 170 | 'test/expected/eachMap/litcoffee.js', 171 | 'Separate compilation of coffee and litcoffee files with source maps should generate javascript'); 172 | 173 | assertFileEquality(test, 174 | 'tmp/eachMap/coffee1.js.map', 175 | 'test/expected/eachMap/coffee1.js.map', 176 | 'Separate compilation of coffee and litcoffee files with source maps should generate map'); 177 | 178 | assertFileEquality(test, 179 | 'tmp/eachMap/litcoffee.js.map', 180 | 'test/expected/eachMap/litcoffee.js.map', 181 | 'Separate compilation of coffee and litcoffee files with source maps should generate map'); 182 | 183 | test.done(); 184 | }, 185 | compileSourceMapDir: function(test) { 186 | test.expect(2); 187 | 188 | assertFileEquality(test, 189 | 'tmp/sourceMapDir1/coffee.js', 190 | 'test/expected/sourceMapDir1/coffee.js', 191 | 'Compilation of single file with source maps should generate javascript'); 192 | 193 | assertFileEquality(test, 194 | 'tmp/sourceMapDir2/coffee.js.map', 195 | 'test/expected/sourceMapDir2/coffee.js.map', 196 | 'Compilation of single file with alternate source map dir should generate map'); 197 | 198 | test.done(); 199 | }, 200 | compileNested: function(test) { 201 | test.expect(2); 202 | 203 | assertFileEquality(test, 204 | 'tmp/nest/1/coffee.js.map', 205 | 'test/expected/maps/coffeeNested.js.map', 206 | 'Compilation of nested maps should respect path info'); 207 | 208 | assertFileEquality(test, 209 | 'tmp/nest/2/coffee.js.map', 210 | 'test/expected/maps/coffeeNested.js.map', 211 | 'Compilation of nested maps should change per file'); 212 | 213 | test.done(); 214 | }, 215 | }; 216 | -------------------------------------------------------------------------------- /test/expected/bare/coffee.js: -------------------------------------------------------------------------------- 1 | var HelloWorld; 2 | 3 | HelloWorld = (function() { 4 | function HelloWorld() {} 5 | 6 | HelloWorld.test = 'test'; 7 | 8 | return HelloWorld; 9 | 10 | })(); 11 | -------------------------------------------------------------------------------- /test/expected/bare/concat.js: -------------------------------------------------------------------------------- 1 | var HelloWorld; 2 | 3 | HelloWorld = (function() { 4 | function HelloWorld() {} 5 | 6 | HelloWorld.test = 'test'; 7 | 8 | return HelloWorld; 9 | 10 | })(); 11 | 12 | console.log('hi'); 13 | 14 | var sayHello; 15 | 16 | sayHello = function() { 17 | return console.log('hi'); 18 | }; 19 | -------------------------------------------------------------------------------- /test/expected/bare/litcoffee.js: -------------------------------------------------------------------------------- 1 | var sayHello; 2 | 3 | sayHello = function() { 4 | return console.log('hi'); 5 | }; 6 | -------------------------------------------------------------------------------- /test/expected/default/coffee.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var HelloWorld; 3 | 4 | HelloWorld = (function() { 5 | function HelloWorld() {} 6 | 7 | HelloWorld.test = 'test'; 8 | 9 | return HelloWorld; 10 | 11 | })(); 12 | 13 | }).call(this); 14 | -------------------------------------------------------------------------------- /test/expected/default/concat.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var HelloWorld; 3 | 4 | HelloWorld = (function() { 5 | function HelloWorld() {} 6 | 7 | HelloWorld.test = 'test'; 8 | 9 | return HelloWorld; 10 | 11 | })(); 12 | 13 | }).call(this); 14 | 15 | (function() { 16 | console.log('hi'); 17 | 18 | }).call(this); 19 | 20 | (function() { 21 | var sayHello; 22 | 23 | sayHello = function() { 24 | return console.log('hi'); 25 | }; 26 | 27 | }).call(this); 28 | -------------------------------------------------------------------------------- /test/expected/default/litcoffee.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var sayHello; 3 | 4 | sayHello = function() { 5 | return console.log('hi'); 6 | }; 7 | 8 | }).call(this); 9 | -------------------------------------------------------------------------------- /test/expected/eachMap/coffee1.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var HelloWorld; 3 | 4 | HelloWorld = (function() { 5 | function HelloWorld() {} 6 | 7 | HelloWorld.test = 'test'; 8 | 9 | return HelloWorld; 10 | 11 | })(); 12 | 13 | }).call(this); 14 | 15 | //# sourceMappingURL=coffee1.js.map 16 | -------------------------------------------------------------------------------- /test/expected/eachMap/coffee1.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "coffee1.js", 4 | "sourceRoot": "../../test/fixtures/", 5 | "sources": [ 6 | "coffee1.coffee" 7 | ], 8 | "names": [], 9 | "mappings": "AAAA;AAAA,MAAA;;EAAM;;;IACJ,UAAC,CAAA,IAAD,GAAO;;;;;AADT" 10 | } -------------------------------------------------------------------------------- /test/expected/eachMap/litcoffee.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var sayHello; 3 | 4 | sayHello = function() { 5 | return console.log('hi'); 6 | }; 7 | 8 | }).call(this); 9 | 10 | //# sourceMappingURL=litcoffee.js.map 11 | -------------------------------------------------------------------------------- /test/expected/eachMap/litcoffee.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "litcoffee.js", 4 | "sourceRoot": "../../test/fixtures/", 5 | "sources": [ 6 | "litcoffee.litcoffee" 7 | ], 8 | "names": [], 9 | "mappings": "AAEI;AAAA,MAAA;;EAAA,QAAA,GAAW,SAAA;WAIT,OAAO,CAAC,GAAR,CAAY,IAAZ;EAJS;AAAX" 10 | } -------------------------------------------------------------------------------- /test/expected/join/bareJoin.js: -------------------------------------------------------------------------------- 1 | var HelloWorld; 2 | 3 | HelloWorld = (function() { 4 | function HelloWorld() {} 5 | 6 | HelloWorld.test = 'test'; 7 | 8 | return HelloWorld; 9 | 10 | })(); 11 | 12 | console.log('hi'); 13 | -------------------------------------------------------------------------------- /test/expected/join/join.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var HelloWorld; 3 | 4 | HelloWorld = (function() { 5 | function HelloWorld() {} 6 | 7 | HelloWorld.test = 'test'; 8 | 9 | return HelloWorld; 10 | 11 | })(); 12 | 13 | console.log('hi'); 14 | 15 | }).call(this); 16 | -------------------------------------------------------------------------------- /test/expected/maps/coffee.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var HelloWorld; 3 | 4 | HelloWorld = (function() { 5 | function HelloWorld() {} 6 | 7 | HelloWorld.test = 'test'; 8 | 9 | return HelloWorld; 10 | 11 | })(); 12 | 13 | }).call(this); 14 | 15 | //# sourceMappingURL=coffee.js.map 16 | -------------------------------------------------------------------------------- /test/expected/maps/coffee.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "coffee.js", 4 | "sourceRoot": "../../test/fixtures/", 5 | "sources": [ 6 | "coffee1.coffee" 7 | ], 8 | "names": [], 9 | "mappings": "AAAA;AAAA,MAAA;;EAAM;;;IACJ,UAAC,CAAA,IAAD,GAAO;;;;;AADT" 10 | } -------------------------------------------------------------------------------- /test/expected/maps/coffeeBare.js: -------------------------------------------------------------------------------- 1 | var HelloWorld; 2 | 3 | HelloWorld = (function() { 4 | function HelloWorld() {} 5 | 6 | HelloWorld.test = 'test'; 7 | 8 | return HelloWorld; 9 | 10 | })(); 11 | 12 | //# sourceMappingURL=coffeeBare.js.map 13 | -------------------------------------------------------------------------------- /test/expected/maps/coffeeBare.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "coffeeBare.js", 4 | "sourceRoot": "../../test/fixtures/", 5 | "sources": [ 6 | "coffee1.coffee" 7 | ], 8 | "names": [], 9 | "mappings": "AAAA,IAAA;;AAAM;;;EACJ,UAAC,CAAA,IAAD,GAAO" 10 | } -------------------------------------------------------------------------------- /test/expected/maps/coffeeBareJoin.js: -------------------------------------------------------------------------------- 1 | var HelloWorld; 2 | 3 | HelloWorld = (function() { 4 | function HelloWorld() {} 5 | 6 | HelloWorld.test = 'test'; 7 | 8 | return HelloWorld; 9 | 10 | })(); 11 | 12 | console.log('hi'); 13 | 14 | //# sourceMappingURL=coffeeBareJoin.js.map 15 | -------------------------------------------------------------------------------- /test/expected/maps/coffeeBareJoin.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "coffeeBareJoin.js", 4 | "sourceRoot": "", 5 | "sources": [ 6 | "coffeeBareJoin.src.coffee" 7 | ], 8 | "names": [], 9 | "mappings": "AAAA,IAAA;;AAAM;;;EACJ,UAAC,CAAA,IAAD,GAAO;;;;;;AACT,OAAO,CAAC,GAAR,CAAY,IAAZ" 10 | } -------------------------------------------------------------------------------- /test/expected/maps/coffeeBareJoin.src.coffee: -------------------------------------------------------------------------------- 1 | class HelloWorld 2 | @test: 'test' 3 | console.log('hi') -------------------------------------------------------------------------------- /test/expected/maps/coffeeJoin.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var HelloWorld; 3 | 4 | HelloWorld = (function() { 5 | function HelloWorld() {} 6 | 7 | HelloWorld.test = 'test'; 8 | 9 | return HelloWorld; 10 | 11 | })(); 12 | 13 | console.log('hi'); 14 | 15 | }).call(this); 16 | 17 | //# sourceMappingURL=coffeeJoin.js.map 18 | -------------------------------------------------------------------------------- /test/expected/maps/coffeeJoin.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "coffeeJoin.js", 4 | "sourceRoot": "", 5 | "sources": [ 6 | "coffeeJoin.src.coffee" 7 | ], 8 | "names": [], 9 | "mappings": "AAAA;AAAA,MAAA;;EAAM;;;IACJ,UAAC,CAAA,IAAD,GAAO;;;;;;EACT,OAAO,CAAC,GAAR,CAAY,IAAZ;AAFA" 10 | } -------------------------------------------------------------------------------- /test/expected/maps/coffeeJoin.src.coffee: -------------------------------------------------------------------------------- 1 | class HelloWorld 2 | @test: 'test' 3 | console.log('hi') -------------------------------------------------------------------------------- /test/expected/maps/coffeeNested.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "coffee.js", 4 | "sourceRoot": "../../../test/fixtures/", 5 | "sources": [ 6 | "coffee1.coffee" 7 | ], 8 | "names": [], 9 | "mappings": "AAAA;AAAA,MAAA;;EAAM;;;IACJ,UAAC,CAAA,IAAD,GAAO;;;;;AADT" 10 | } -------------------------------------------------------------------------------- /test/expected/react/coffee-react.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | /** @jsx React.DOM */; 3 | var Car; 4 | 5 | Car = React.createClass({displayName: "Car", 6 | render: function() { 7 | var ref; 8 | return React.createElement(Vehicle, { 9 | "doors": 4., 10 | "locked": isLocked(), 11 | "data-colour": "red", 12 | "on": true 13 | }, React.createElement(Parts.FrontSeat, null), React.createElement(Parts.BackSeat, null), React.createElement("p", { 14 | "className": "kickin" 15 | }, "Which seat can I take? ", ((ref = this.props) != null ? ref.seat : void 0) || 'none')); 16 | } 17 | }); 18 | 19 | }).call(this); 20 | -------------------------------------------------------------------------------- /test/expected/sourceMapDir1/coffee.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var HelloWorld; 3 | 4 | HelloWorld = (function() { 5 | function HelloWorld() {} 6 | 7 | HelloWorld.test = 'test'; 8 | 9 | return HelloWorld; 10 | 11 | })(); 12 | 13 | }).call(this); 14 | 15 | //# sourceMappingURL=../sourceMapDir2/coffee.js.map 16 | -------------------------------------------------------------------------------- /test/expected/sourceMapDir2/coffee.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "coffee.js", 4 | "sourceRoot": "../../test/fixtures/", 5 | "sources": [ 6 | "coffee1.coffee" 7 | ], 8 | "names": [], 9 | "mappings": "AAAA;AAAA,MAAA;;EAAM;;;IACJ,UAAC,CAAA,IAAD,GAAO;;;;;AADT" 10 | } -------------------------------------------------------------------------------- /test/fixtures/coffee-react.cjsx: -------------------------------------------------------------------------------- 1 | # @cjsx React.DOM 2 | Car = React.createClass 3 | render: -> 4 | 5 | 6 | 7 |

Which seat can I take? {@props?.seat or 'none'}

8 |
9 | -------------------------------------------------------------------------------- /test/fixtures/coffee1.coffee: -------------------------------------------------------------------------------- 1 | class HelloWorld 2 | @test: 'test' -------------------------------------------------------------------------------- /test/fixtures/coffee2.coffee: -------------------------------------------------------------------------------- 1 | console.log('hi') -------------------------------------------------------------------------------- /test/fixtures/litcoffee.coffee.md: -------------------------------------------------------------------------------- 1 | Begin function declaration. 2 | 3 | sayHello = -> 4 | 5 | Print a greeting. 6 | 7 | console.log 'hi' 8 | -------------------------------------------------------------------------------- /test/fixtures/litcoffee.litcoffee: -------------------------------------------------------------------------------- 1 | Begin function declaration. 2 | 3 | sayHello = -> 4 | 5 | Print a greeting. 6 | 7 | console.log 'hi' 8 | -------------------------------------------------------------------------------- /update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | git pull origin master 4 | DEPENDENCY="coffee-react" 5 | VERSION=$(npm view ${DEPENDENCY} version) 6 | echo "updating to $VERSION" 7 | npm install --save "${DEPENDENCY}@${VERSION}" 8 | npm test 9 | git add ./package.json 10 | git commit -m "updated ${DEPENDENCY} to v${VERSION}" 11 | npm version "$VERSION" 12 | read -p "will publish $VERSION. are you sure? " -n 1 -r 13 | echo 14 | if [[ $REPLY =~ ^[Yy]$ ]] 15 | then 16 | git push origin master 17 | git push --tags 18 | npm publish . 19 | fi 20 | --------------------------------------------------------------------------------