├── .gitattributes ├── .gitignore ├── .jshintrc ├── .npmrc ├── .travis.yml ├── AUTHORS ├── CHANGELOG ├── CONTRIBUTING.md ├── Gruntfile.js ├── LICENSE-MIT ├── README.md ├── appveyor.yml ├── docs ├── coffee-examples.md ├── coffee-options.md ├── coffee-overview.md └── overview.md ├── package-lock.json ├── package.json ├── tasks └── coffee.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 ├── litCoffeeMaps │ ├── litcoffee.js │ ├── litcoffee.js.map │ ├── mdcoffee.js │ └── mdcoffee.js.map ├── 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 ├── sourceMapDir1 │ └── coffee.js └── sourceMapDir2 │ └── coffee.js.map └── fixtures ├── coffee1.coffee ├── coffee2.coffee ├── litcoffee.coffee.md ├── litcoffee.litcoffee ├── litcoffee1.litcoffee ├── mdcoffee.coffee.md └── mdcoffee1.coffee.md /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | tmp -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "boss": true, 3 | "curly": true, 4 | "eqeqeq": true, 5 | "eqnull": true, 6 | "immed": true, 7 | "latedef": false, 8 | "newcap": true, 9 | "noarg": true, 10 | "node": true, 11 | "sub": true, 12 | "undef": true, 13 | "unused": true 14 | } 15 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | lockfile-version=2 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | 3 | language: node_js 4 | 5 | node_js: 6 | - "8" 7 | - "10" 8 | 9 | matrix: 10 | fast_finish: true 11 | 12 | cache: 13 | directories: 14 | - node_modules 15 | -------------------------------------------------------------------------------- /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 | v2.1.0: 2 | date: 2019-03-18 3 | changes: 4 | - Updates to CoffeeScript 2.3.2. 5 | v2.0.0: 6 | date: 2017-09-27 7 | changes: 8 | - Updates to CoffeeScript 2.0.1. 9 | v1.0.0: 10 | date: 2016-02-15 11 | changes: 12 | - Updates to CoffeeScript 1.10.0. 13 | - Update other dependencies. 14 | - Use `options.sourceMapDir` when creating `sourceRoot`. 15 | - Logs information if no valid files were matched. 16 | v0.13.0: 17 | date: 2015-02-20 18 | changes: 19 | - Updates to CoffeeScript 1.9.1. 20 | v0.12.0: 21 | date: 2014-10-04 22 | changes: 23 | - Fixes litcoffee sourcemaps. 24 | - Updates to CoffeeScript 1.8.0. 25 | v0.11.1: 26 | date: 2014-08-15 27 | changes: 28 | - Fixes summary logging. 29 | v0.11.0: 30 | date: 2014-08-06 31 | changes: 32 | - Adds summary containing number of files created. 33 | - Move file creation logging to `grunt.verbose`. 34 | - Updates chalk to 0.5. 35 | v0.10.0: 36 | date: 2014-02-07 37 | changes: 38 | - '`sourceMappingURL` calculated correctly.' 39 | v0.9.0: 40 | date: 2014-01-29 41 | changes: 42 | - Source mapping fixes. 43 | - Update CoffeeScript to 1.7.0. 44 | - Use lodash directly instead of deprecated `grunt.util._`. 45 | v0.8.2: 46 | date: 2014-01-17 47 | changes: 48 | - Force CoffeeScript 1.6.3. 49 | - Use new `sourceMappingUrl` syntax. 50 | v0.8.1: 51 | date: 2014-01-17 52 | changes: 53 | - Fix sourcemap regression. 54 | v0.8.0: 55 | date: 2013-12-24 56 | changes: 57 | - Support `sourceMapDir`. 58 | v0.7.0: 59 | date: 2013-04-19 60 | changes: 61 | - Place source maps at bottom of file. 62 | - Change extension for source maps from .maps to .js.map. 63 | v0.6.7: 64 | date: 2013-04-18 65 | changes: 66 | - Improved error reporting. 67 | v0.6.6: 68 | date: 2013-04-08 69 | changes: 70 | - Fix regression with single-file compilation. 71 | v0.6.5: 72 | date: 2013-04-05 73 | changes: 74 | - Improved error reporting. 75 | v0.6.4: 76 | date: 2013-03-22 77 | changes: 78 | - Sourcemap support. 79 | v0.6.3: 80 | date: 2013-03-19 81 | changes: 82 | - Increase error logging verbosity. 83 | v0.6.2: 84 | date: 2013-03-18 85 | changes: 86 | - Bump to CoffeeScript 1.6.2. 87 | v0.6.1: 88 | date: 2013-03-18 89 | changes: 90 | - Support `join` option. 91 | v0.6.0: 92 | date: 2013-03-06 93 | changes: 94 | - Bump to CoffeeScript 1.6. 95 | - Support literate CoffeeScript extension coffee.md. 96 | v0.5.0: 97 | date: 2013-02-25 98 | changes: 99 | - Bump to CoffeeScript 1.5. 100 | - Support literate CoffeeScript (.litcoffee). 101 | v0.4.0: 102 | date: 2013-02-15 103 | changes: 104 | - First official release for Grunt 0.4.0. 105 | v0.4.0rc7: 106 | date: 2013-01-23 107 | changes: 108 | - Updating grunt/gruntplugin dependencies to rc7. 109 | - Changing in-development grunt/gruntplugin dependency versions from tilde version ranges to specific versions. 110 | - Bump coffeescript dependency to 1.4. 111 | v0.4.0rc5: 112 | date: 2013-01-09 113 | changes: 114 | - Updating to work with grunt v0.4.0rc5. 115 | - Switching to `this.filesSrc` API. 116 | v0.4.0a: 117 | date: 2012-12-15 118 | changes: 119 | - Conversion to grunt v0.4 conventions. 120 | - Remove experimental destination wildcards. 121 | v0.3.2: 122 | date: 2012-10-12 123 | changes: 124 | - Rename grunt-contrib-lib dep to grunt-lib-contrib. 125 | v0.3.1: 126 | date: 2012-09-25 127 | changes: 128 | - Don't fail when there are no files. 129 | v0.3.0: 130 | date: 2012-09-24 131 | changes: 132 | - Global options depreciated. 133 | v0.2.0: 134 | date: 2012-09-10 135 | changes: 136 | - Refactored from grunt-contrib into individual repo. 137 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Please see the [Contributing to grunt](https://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) 2016 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 | coffee: { 44 | compileDefault: { 45 | files: { 46 | 'tmp/default/coffee.js': ['test/fixtures/coffee1.coffee'], 47 | 'tmp/default/litcoffee.js': ['test/fixtures/litcoffee.litcoffee'], 48 | 'tmp/default/litcoffeemd.js': ['test/fixtures/litcoffee.coffee.md'], 49 | 'tmp/default/concat.js': mixedConcatFixtures 50 | } 51 | }, 52 | compileBare: { 53 | options: { 54 | bare: true 55 | }, 56 | files: { 57 | 'tmp/bare/coffee.js': ['test/fixtures/coffee1.coffee'], 58 | 'tmp/bare/litcoffee.js': ['test/fixtures/litcoffee.litcoffee'], 59 | 'tmp/bare/litcoffeemd.js': ['test/fixtures/litcoffee.coffee.md'], 60 | 'tmp/bare/concat.js': mixedConcatFixtures 61 | } 62 | }, 63 | compileJoined: { 64 | options: { 65 | join: true 66 | }, 67 | files: { 68 | 'tmp/join/coffee.js': ['test/fixtures/coffee1.coffee'], 69 | 'tmp/join/join.js': uniformConcatFixtures 70 | } 71 | }, 72 | compileBareJoined: { 73 | options: { 74 | bare: true, 75 | join: true 76 | }, 77 | files: { 78 | 'tmp/join/bareCoffee.js': ['test/fixtures/coffee1.coffee'], 79 | 'tmp/join/bareJoin.js': uniformConcatFixtures 80 | } 81 | }, 82 | compileMaps: { 83 | options: { 84 | sourceMap: true 85 | }, 86 | files: { 87 | 'tmp/maps/coffee.js': ['test/fixtures/coffee1.coffee'], 88 | 'tmp/maps/coffeeJoin.js': uniformConcatFixtures 89 | } 90 | }, 91 | compileSourceMapDir: { 92 | options: { 93 | sourceMap: true, 94 | sourceMapDir: 'tmp/sourceMapDir2' 95 | }, 96 | files: { 97 | 'tmp/sourceMapDir1/coffee.js': ['test/fixtures/coffee1.coffee'] 98 | } 99 | }, 100 | compileEachMap: { 101 | options: { 102 | sourceMap: true 103 | }, 104 | files: [{ 105 | expand: true, 106 | cwd: 'test/fixtures/', 107 | src: ['coffee1.coffee', 'litcoffee.litcoffee'], 108 | dest: 'tmp/eachMap/', 109 | ext: '.js' 110 | }] 111 | }, 112 | compileBareMaps: { 113 | options: { 114 | sourceMap: true, 115 | bare: true 116 | }, 117 | files: { 118 | 'tmp/maps/coffeeBare.js': ['test/fixtures/coffee1.coffee'], 119 | 'tmp/maps/coffeeBareJoin.js': uniformConcatFixtures 120 | } 121 | }, 122 | compileNested: { 123 | options: { 124 | sourceMap: true 125 | }, 126 | files: { 127 | 'tmp/nest/1/coffee.js': ['test/fixtures/coffee1.coffee'], 128 | 'tmp/nest/2/coffee.js': ['test/fixtures/coffee1.coffee'] 129 | } 130 | }, 131 | compileMDCoffeeMaps: { 132 | options: { 133 | sourceMap: true, 134 | joinExt: '.src.coffee.md' 135 | }, 136 | files: [{ 137 | 'tmp/litCoffeeMaps/mdcoffee.js': ['test/fixtures/mdcoffee.coffee.md', 'test/fixtures/mdcoffee1.coffee.md'] 138 | }] 139 | }, 140 | compileLitCoffeeMaps: { 141 | options: { 142 | sourceMap: true, 143 | joinExt: '.src.litcoffee' 144 | }, 145 | files: [{ 146 | 'tmp/litCoffeeMaps/litcoffee.js': ['test/fixtures/litcoffee.litcoffee', 'test/fixtures/litcoffee1.litcoffee'] 147 | }] 148 | } 149 | }, 150 | 151 | // Unit tests. 152 | nodeunit: { 153 | tests: ['test/*_test.js'] 154 | } 155 | }); 156 | 157 | // Actually load this plugin's task(s). 158 | grunt.loadTasks('tasks'); 159 | 160 | // These plugins provide necessary tasks. 161 | grunt.loadNpmTasks('grunt-contrib-jshint'); 162 | grunt.loadNpmTasks('grunt-contrib-clean'); 163 | grunt.loadNpmTasks('grunt-contrib-nodeunit'); 164 | grunt.loadNpmTasks('grunt-contrib-internal'); 165 | 166 | // Whenever the "test" task is run, first clean the "tmp" dir, then run this 167 | // plugin's task(s), then test the result. 168 | grunt.registerTask('test', ['jshint', 'clean', 'coffee', 'nodeunit']); 169 | 170 | // By default, lint and run all tests. 171 | grunt.registerTask('default', ['test', 'contrib-core']); 172 | 173 | }; 174 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 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-contrib-coffee v2.1.0 [![Build Status: Linux](https://travis-ci.org/gruntjs/grunt-contrib-coffee.svg?branch=master)](https://travis-ci.org/gruntjs/grunt-contrib-coffee) [![Build Status: Windows](https://ci.appveyor.com/api/projects/status/ns3waxwcw8ddcr3f/branch/master?svg=true)](https://ci.appveyor.com/project/gruntjs/grunt-contrib-coffee/branch/master) 2 | 3 | > Compile CoffeeScript files to JavaScript 4 | 5 | 6 | 7 | ## Getting Started 8 | 9 | If you haven't used [Grunt](https://gruntjs.com/) before, be sure to check out the [Getting Started](https://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](https://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: 10 | 11 | ```shell 12 | npm install grunt-contrib-coffee --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-contrib-coffee'); 19 | ``` 20 | 21 | *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).* 22 | 23 | 24 | 25 | ## Coffee task 26 | _Run this task with the `grunt coffee` command._ 27 | 28 | Task targets, files and options may be specified according to the grunt [Configuring tasks](http://gruntjs.com/configuring-tasks) guide. 29 | ### Options 30 | 31 | #### separator 32 | Type: `String` 33 | Default: linefeed 34 | 35 | Concatenated files will be joined on this string. 36 | 37 | #### bare 38 | Type: `Boolean` 39 | 40 | Compile the JavaScript without the top-level function safety wrapper. 41 | 42 | #### join 43 | Type: `Boolean` 44 | Default: `false` 45 | 46 | When compiling multiple .coffee files into a single .js file, concatenate first. 47 | 48 | #### sourceMap 49 | Type: `Boolean` 50 | Default: `false` 51 | 52 | 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 53 | 54 | #### sourceMapDir 55 | Type: `String` 56 | Default: (same path as your compiled js files) 57 | 58 | Generated source map files will be created here. 59 | 60 | #### joinExt 61 | Type: `String` 62 | Default: '.src.coffee' 63 | 64 | Resulting extension when joining multiple CoffeeScript files. 65 | 66 | ### Usage Examples 67 | 68 | ```js 69 | coffee: { 70 | compile: { 71 | files: { 72 | 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile 73 | 'path/to/another.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // compile and concat into single file 74 | } 75 | }, 76 | 77 | compileBare: { 78 | options: { 79 | bare: true 80 | }, 81 | files: { 82 | 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile 83 | 'path/to/another.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // compile and concat into single file 84 | } 85 | }, 86 | 87 | compileJoined: { 88 | options: { 89 | join: true 90 | }, 91 | files: { 92 | 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile, identical output to join = false 93 | 'path/to/another.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // concat then compile into single file 94 | } 95 | }, 96 | 97 | compileWithMaps: { 98 | options: { 99 | sourceMap: true 100 | }, 101 | files: { 102 | 'path/to/result.js': 'path/to/source.coffee', // 1:1 compile 103 | 'path/to/another.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // concat then compile into single file 104 | } 105 | }, 106 | 107 | compileWithMapsDir: { 108 | options: { 109 | sourceMap: true, 110 | sourceMapDir: 'path/to/maps/' // source map files will be created here 111 | }, 112 | files: { 113 | 'path/to/result.js': 'path/to/source.coffee' 114 | } 115 | }, 116 | 117 | glob_to_multiple: { 118 | expand: true, 119 | flatten: true, 120 | cwd: 'path/to', 121 | src: ['*.coffee'], 122 | dest: 'path/to/dest/', 123 | ext: '.js' 124 | } 125 | 126 | } 127 | ``` 128 | 129 | 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). 130 | 131 | 132 | ## Release History 133 | 134 | * 2019-03-18   v2.1.0   Updates to CoffeeScript 2.3.2. 135 | * 2017-09-27   v2.0.0   Updates to CoffeeScript 2.0.1. 136 | * 2016-02-15   v1.0.0   Updates to CoffeeScript 1.10.0. Update other dependencies. Use `options.sourceMapDir` when creating `sourceRoot`. Logs information if no valid files were matched. 137 | * 2015-02-20   v0.13.0   Updates to CoffeeScript 1.9.1. 138 | * 2014-10-04   v0.12.0   Fixes litcoffee sourcemaps. Updates to CoffeeScript 1.8.0. 139 | * 2014-08-15   v0.11.1   Fixes summary logging. 140 | * 2014-08-06   v0.11.0   Adds summary containing number of files created. Move file creation logging to `grunt.verbose`. Updates chalk to 0.5. 141 | * 2014-02-07   v0.10.0   `sourceMappingURL` calculated correctly. 142 | * 2014-01-29   v0.9.0   Source mapping fixes. Update CoffeeScript to 1.7.0. Use lodash directly instead of deprecated `grunt.util._`. 143 | * 2014-01-17   v0.8.2   Force CoffeeScript 1.6.3. Use new `sourceMappingUrl` syntax. 144 | * 2014-01-17   v0.8.1   Fix sourcemap regression. 145 | * 2013-12-24   v0.8.0   Support `sourceMapDir`. 146 | * 2013-04-19   v0.7.0   Place source maps at bottom of file. Change extension for source maps from .maps to .js.map. 147 | * 2013-04-18   v0.6.7   Improved error reporting. 148 | * 2013-04-08   v0.6.6   Fix regression with single-file compilation. 149 | * 2013-04-05   v0.6.5   Improved error reporting. 150 | * 2013-03-22   v0.6.4   Sourcemap support. 151 | * 2013-03-19   v0.6.3   Increase error logging verbosity. 152 | * 2013-03-18   v0.6.2   Bump to CoffeeScript 1.6.2. 153 | * 2013-03-18   v0.6.1   Support `join` option. 154 | * 2013-03-06   v0.6.0   Bump to CoffeeScript 1.6. Support literate CoffeeScript extension coffee.md. 155 | * 2013-02-25   v0.5.0   Bump to CoffeeScript 1.5. Support literate CoffeeScript (.litcoffee). 156 | * 2013-02-15   v0.4.0   First official release for Grunt 0.4.0. 157 | * 2013-01-23   v0.4.0rc7   Updating grunt/gruntplugin dependencies to rc7. Changing in-development grunt/gruntplugin dependency versions from tilde version ranges to specific versions. Bump coffeescript dependency to 1.4. 158 | * 2013-01-09   v0.4.0rc5   Updating to work with grunt v0.4.0rc5. Switching to `this.filesSrc` API. 159 | * 2012-12-15   v0.4.0a   Conversion to grunt v0.4 conventions. Remove experimental destination wildcards. 160 | * 2012-10-12   v0.3.2   Rename grunt-contrib-lib dep to grunt-lib-contrib. 161 | * 2012-09-25   v0.3.1   Don't fail when there are no files. 162 | * 2012-09-24   v0.3.0   Global options depreciated. 163 | * 2012-09-10   v0.2.0   Refactored from grunt-contrib into individual repo. 164 | 165 | --- 166 | 167 | Task submitted by [Eric Woroshow](http://ericw.ca/) 168 | 169 | *This file was generated on Mon Mar 18 2019 14:04:56.* 170 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | clone_depth: 10 2 | 3 | version: "{build}" 4 | 5 | # What combinations to test 6 | environment: 7 | matrix: 8 | - nodejs_version: "8" 9 | platform: x86 10 | - nodejs_version: "10" 11 | platform: x86 12 | 13 | install: 14 | - ps: Install-Product node $env:nodejs_version $env:platform 15 | - npm install 16 | 17 | test_script: 18 | # Output useful info for debugging 19 | - node --version && npm --version 20 | # We test multiple Windows shells because of prior stdout buffering issues 21 | # filed against Grunt. https://github.com/joyent/node/issues/3584 22 | - ps: "npm test # PowerShell" # Pass comment to PS for easier debugging 23 | - cmd: npm test 24 | 25 | build: off 26 | 27 | matrix: 28 | fast_finish: true 29 | 30 | cache: 31 | - node_modules -> package.json 32 | -------------------------------------------------------------------------------- /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).* 2 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "grunt-contrib-coffee", 3 | "description": "Compile CoffeeScript files to JavaScript", 4 | "version": "2.1.0", 5 | "author": { 6 | "name": "Grunt Team", 7 | "url": "http://gruntjs.com/" 8 | }, 9 | "repository": "gruntjs/grunt-contrib-coffee", 10 | "license": "MIT", 11 | "engines": { 12 | "node": ">=8" 13 | }, 14 | "main": "tasks/coffee.js", 15 | "scripts": { 16 | "test": "grunt test" 17 | }, 18 | "dependencies": { 19 | "chalk": "^2.4.2", 20 | "coffeescript": "^2.7.0", 21 | "lodash": "^4.17.21", 22 | "uri-path": "^1.0.0" 23 | }, 24 | "devDependencies": { 25 | "grunt": "^1.4.1", 26 | "grunt-contrib-clean": "^2.0.1", 27 | "grunt-contrib-internal": "^3.1.0", 28 | "grunt-contrib-jshint": "^3.2.0", 29 | "grunt-contrib-nodeunit": "^5.0.0" 30 | }, 31 | "peerDependencies": { 32 | "grunt": ">=0.4.5" 33 | }, 34 | "keywords": [ 35 | "gruntplugin" 36 | ], 37 | "files": [ 38 | "tasks" 39 | ], 40 | "appveyor_id": "ns3waxwcw8ddcr3f" 41 | } 42 | -------------------------------------------------------------------------------- /tasks/coffee.js: -------------------------------------------------------------------------------- 1 | /* 2 | * grunt-contrib-coffee 3 | * http://gruntjs.com/ 4 | * 5 | * Copyright (c) 2016 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 | var uriPath = require('uri-path'); 16 | 17 | grunt.registerMultiTask('coffee', 'Compile CoffeeScript files into JavaScript', function() { 18 | var options = this.options({ 19 | bare: false, 20 | join: false, 21 | sourceMap: false, 22 | joinExt: '.src.coffee', 23 | separator: grunt.util.linefeed 24 | }); 25 | var actionCounts = { 26 | createdFile: 0, 27 | createdMap: 0 28 | }; 29 | 30 | options.separator = grunt.util.normalizelf(options.separator); 31 | 32 | this.files.forEach(function(f) { 33 | var validFiles = removeInvalidFiles(f); 34 | 35 | if (validFiles.length === 0) { 36 | grunt.log.warn('Destination ' + chalk.cyan(f.dest) + ' not written because no source files were found.'); 37 | return; 38 | } 39 | 40 | if (options.sourceMap === true) { 41 | var paths = createOutputPaths(f.dest); 42 | // add sourceMapDir to options object 43 | var fileOptions = _.extend({ sourceMapDir: paths.destDir }, options); 44 | var writeResult = writeFileAndMap(paths, compileWithMaps(validFiles, fileOptions, paths), fileOptions); 45 | actionCounts.createdFile += writeResult.createdFile; 46 | actionCounts.createdMap += writeResult.createdMap; 47 | } else if (options.join === true) { 48 | actionCounts.createdFile += writeCompiledFile(f.dest, concatInput(validFiles, options)); 49 | } else { 50 | actionCounts.createdFile += writeCompiledFile(f.dest, concatOutput(validFiles, options)); 51 | } 52 | }); 53 | 54 | grunt.log.ok(actionCounts.createdFile + ' files created.'); 55 | if (actionCounts.createdMap > 0) { 56 | grunt.log.ok(actionCounts.createdMap + ' source map files created.'); 57 | } 58 | }); 59 | 60 | var isLiterate = function(ext) { 61 | return ext === '.litcoffee' || ext === '.md'; 62 | }; 63 | 64 | var removeInvalidFiles = function(files) { 65 | return files.src.filter(function(filepath) { 66 | if (!grunt.file.exists(filepath)) { 67 | grunt.log.warn('Source file "' + filepath + '" not found.'); 68 | return false; 69 | } 70 | return true; 71 | }); 72 | }; 73 | 74 | var createOutputPaths = function(destination) { 75 | var fileName = path.basename(destination, path.extname(destination)); 76 | return { 77 | dest: destination, 78 | destName: fileName, 79 | destDir: appendTrailingSlash(path.dirname(destination)), 80 | mapFileName: fileName + '.js.map' 81 | }; 82 | }; 83 | 84 | var appendTrailingSlash = function(dirname) { 85 | if (dirname.length > 0 && dirname.slice(-1) !== path.sep) { 86 | return dirname + path.sep; 87 | } 88 | return dirname; 89 | }; 90 | 91 | var compileWithMaps = function(files, options, paths) { 92 | if (!hasUniformExtensions(files)) { 93 | return; 94 | } 95 | 96 | var mapOptions, filepath; 97 | 98 | if (files.length > 1) { 99 | mapOptions = createOptionsForJoin(files, paths, options.separator, options.joinExt); 100 | } else { 101 | mapOptions = createOptionsForFile(files[0], paths, options); 102 | filepath = files[0]; 103 | } 104 | 105 | options = _.extend({ 106 | generatedFile: path.basename(paths.dest), 107 | sourceRoot: uriPath(mapOptions.sourceRoot), 108 | sourceFiles: mapOptions.sourceFiles 109 | }, options); 110 | 111 | var output = compileCoffee(mapOptions.code, options, filepath); 112 | appendFooter(output, paths, options); 113 | return output; 114 | }; 115 | 116 | var hasUniformExtensions = function(files) { 117 | // get all extensions for input files 118 | var extensions = _.uniq(files.map(path.extname)); 119 | 120 | if (extensions.length > 1) { 121 | grunt.fail.warn('Join and sourceMap options require input files share the same extension (found ' + extensions.join(', ') + ').'); 122 | return false; 123 | } 124 | return true; 125 | }; 126 | 127 | var createOptionsForJoin = function (files, paths, separator, joinExt) { 128 | var code = concatFiles(files, separator); 129 | var targetFileName = paths.destName + joinExt; 130 | grunt.file.write(paths.destDir + targetFileName, code); 131 | 132 | return { 133 | code: code, 134 | sourceFiles: [targetFileName], 135 | sourceRoot: '' 136 | }; 137 | }; 138 | 139 | var concatFiles = function(files, separator) { 140 | return files.map(grunt.file.read).join(separator); 141 | }; 142 | 143 | var createOptionsForFile = function(file, paths, options) { 144 | return { 145 | code: grunt.file.read(file), 146 | sourceFiles: [path.basename(file)], 147 | sourceRoot: appendTrailingSlash(path.relative(options.sourceMapDir, path.dirname(file))) 148 | }; 149 | }; 150 | 151 | var appendFooter = function(output, paths, options) { 152 | // We need the sourceMappingURL to be relative to the JS path 153 | var sourceMappingDir = appendTrailingSlash(path.relative(paths.destDir, options.sourceMapDir)); 154 | // Add sourceMappingURL to file footer 155 | output.js = output.js + '\n//# sourceMappingURL=' + uriPath(sourceMappingDir) + paths.mapFileName + '\n'; 156 | }; 157 | 158 | var concatInput = function(files, options) { 159 | if (hasUniformExtensions(files)) { 160 | var code = concatFiles(files, options.separator); 161 | return compileCoffee(code, options); 162 | } 163 | }; 164 | 165 | var concatOutput = function(files, options) { 166 | return files.map(function(filepath) { 167 | var code = grunt.file.read(filepath); 168 | return compileCoffee(code, options, filepath); 169 | }).join(options.separator); 170 | }; 171 | 172 | var compileCoffee = function(code, options, filepath) { 173 | var coffeeOptions = _.clone(options); 174 | if (filepath) { 175 | coffeeOptions.filename = filepath; 176 | coffeeOptions.literate = isLiterate(path.extname(filepath)); 177 | } else { 178 | coffeeOptions.literate = isLiterate(path.extname(options.joinExt)); 179 | } 180 | 181 | try { 182 | return require('coffeescript').compile(code, coffeeOptions); 183 | } catch (e) { 184 | if (e.location == null || 185 | e.location.first_column == null || 186 | e.location.first_line == null) { 187 | grunt.log.error('Got an unexpected exception ' + 188 | 'from the coffee-script compiler. ' + 189 | 'The original exception was: ' + 190 | e); 191 | grunt.log.error('(The coffee-script compiler should not raise *unexpected* exceptions. ' + 192 | 'You can file this error as an issue of the coffee-script compiler: ' + 193 | 'https://github.com/jashkenas/coffee-script/issues)'); 194 | } else { 195 | var firstColumn = e.location.first_column; 196 | var firstLine = e.location.first_line; 197 | var codeLine = code.split('\n')[firstLine]; 198 | var errorArrows = chalk.red('>>') + ' '; 199 | var offendingCharacter; 200 | 201 | if (firstColumn < codeLine.length) { 202 | offendingCharacter = chalk.red(codeLine[firstColumn]); 203 | } else { 204 | offendingCharacter = ''; 205 | } 206 | 207 | grunt.log.error(e); 208 | grunt.log.error('In file: ' + filepath); 209 | grunt.log.error('On line: ' + firstLine); 210 | // log erroneous line and highlight offending character 211 | // grunt.log.error trims whitespace so we have to use grunt.log.writeln 212 | grunt.log.writeln(errorArrows + codeLine.substring(0, firstColumn) + 213 | offendingCharacter + codeLine.substring(firstColumn + 1)); 214 | grunt.log.writeln(errorArrows + grunt.util.repeat(firstColumn, ' ') + 215 | chalk.red('^')); 216 | } 217 | grunt.fail.warn('CoffeeScript failed to compile.'); 218 | } 219 | }; 220 | 221 | var writeFileAndMap = function(paths, output, options) { 222 | if (!output || output.js.length === 0) { 223 | warnOnEmptyFile(paths.dest); 224 | return; 225 | } 226 | 227 | var createdFile = writeCompiledFile(paths.dest, output.js); 228 | options.sourceMapDir = appendTrailingSlash(options.sourceMapDir); 229 | var createdMap = writeSourceMapFile(options.sourceMapDir + paths.mapFileName, output.v3SourceMap); 230 | 231 | return { 232 | createdFile: createdFile, 233 | createdMap: createdMap 234 | }; 235 | }; 236 | 237 | var warnOnEmptyFile = function(path) { 238 | grunt.log.warn('Destination "' + path + '" not written because compiled files were empty.'); 239 | }; 240 | 241 | var writeFile = function(path, output) { 242 | if (output.length < 1) { 243 | warnOnEmptyFile(path); 244 | return false; 245 | } 246 | grunt.file.write(path, output); 247 | return true; 248 | }; 249 | 250 | var writeCompiledFile = function(path, output) { 251 | if (writeFile(path, output)) { 252 | grunt.verbose.writeln('File ' + chalk.cyan(path) + ' created.'); 253 | return 1; 254 | } 255 | return 0; 256 | }; 257 | var writeSourceMapFile = function(path, output) { 258 | if (writeFile(path, output)) { 259 | grunt.verbose.writeln('File ' + chalk.cyan(path) + ' created (source map).'); 260 | return 1; 261 | } 262 | return 0; 263 | }; 264 | }; 265 | -------------------------------------------------------------------------------- /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 | contents = contents.replace(/\\r\\n/g, '\\n'); 10 | } 11 | return contents; 12 | } 13 | 14 | function assertFileEquality(test, pathToActual, pathToExpected, message) { 15 | var actual = readFile(pathToActual); 16 | var expected = readFile(pathToExpected); 17 | test.equal(expected, actual, message); 18 | } 19 | 20 | exports.coffee = { 21 | compileBare: function(test) { 22 | test.expect(4); 23 | 24 | assertFileEquality(test, 25 | 'tmp/bare/coffee.js', 26 | 'test/expected/bare/coffee.js', 27 | 'Should compile coffeescript to unwrapped javascript'); 28 | 29 | assertFileEquality(test, 30 | 'tmp/bare/litcoffee.js', 31 | 'test/expected/bare/litcoffee.js', 32 | 'Should compile literate coffeescript to unwrapped javascript'); 33 | 34 | assertFileEquality(test, 35 | 'tmp/bare/litcoffeemd.js', 36 | 'test/expected/bare/litcoffee.js', 37 | 'Should compile literate coffeescript to unwrapped javascript'); 38 | 39 | assertFileEquality(test, 40 | 'tmp/bare/concat.js', 41 | 'test/expected/bare/concat.js', 42 | 'Should compile coffeescript files without wrappers and concatenate them into a single javascript file'); 43 | 44 | test.done(); 45 | }, 46 | compileDefault: function(test) { 47 | test.expect(4); 48 | 49 | assertFileEquality(test, 50 | 'tmp/default/coffee.js', 51 | 'test/expected/default/coffee.js', 52 | 'Should compile coffeescript to javascript'); 53 | 54 | assertFileEquality(test, 55 | 'tmp/default/litcoffee.js', 56 | 'test/expected/default/litcoffee.js', 57 | 'Should compile literate coffeescript to wrapped javascript'); 58 | 59 | assertFileEquality(test, 60 | 'tmp/default/litcoffeemd.js', 61 | 'test/expected/default/litcoffee.js', 62 | 'Should compile literate coffeescript to wrapped javascript'); 63 | 64 | assertFileEquality(test, 65 | 'tmp/default/concat.js', 66 | 'test/expected/default/concat.js', 67 | 'Should compile coffeescript files with wrappers and concatenate them into a single javascript file'); 68 | 69 | test.done(); 70 | }, 71 | compileJoined: function(test) { 72 | test.expect(4); 73 | 74 | assertFileEquality(test, 75 | 'tmp/join/coffee.js', 76 | 'test/expected/default/coffee.js', 77 | 'Compilation of one file with join enabled should match normal compilation'); 78 | 79 | assertFileEquality(test, 80 | 'tmp/join/join.js', 81 | 'test/expected/join/join.js', 82 | 'Should concatenate coffeescript files prior to compilation into a single javascript file'); 83 | 84 | assertFileEquality(test, 85 | 'tmp/join/bareCoffee.js', 86 | 'test/expected/bare/coffee.js', 87 | 'Bare compilation of one file with join enabled should match bare compilation'); 88 | 89 | assertFileEquality(test, 90 | 'tmp/join/bareJoin.js', 91 | 'test/expected/join/bareJoin.js', 92 | 'Bare compilation of multiple join files should be equivalent to concatenated compilation'); 93 | 94 | test.done(); 95 | }, 96 | compileMaps: function(test) { 97 | 98 | test.expect(10); 99 | assertFileEquality(test, 100 | 'tmp/maps/coffee.js', 101 | 'test/expected/maps/coffee.js', 102 | 'Compilation of single file with source maps should generate javascript'); 103 | 104 | assertFileEquality(test, 105 | 'tmp/maps/coffee.js.map', 106 | 'test/expected/maps/coffee.js.map', 107 | 'Compilation of single file with source maps should generate map'); 108 | 109 | assertFileEquality(test, 110 | 'tmp/maps/coffeeJoin.js', 111 | 'test/expected/maps/coffeeJoin.js', 112 | 'Compilation of multiple files with source maps should generate javascript'); 113 | 114 | assertFileEquality(test, 115 | 'tmp/maps/coffeeJoin.js.map', 116 | 'test/expected/maps/coffeeJoin.js.map', 117 | 'Compilation of multiple files with source maps should generate map'); 118 | 119 | assertFileEquality(test, 120 | 'tmp/maps/coffeeJoin.src.coffee', 121 | 'test/expected/maps/coffeeJoin.src.coffee', 122 | 'Compilation of multiple files with source maps should output concatenated source'); 123 | 124 | assertFileEquality(test, 125 | 'tmp/maps/coffeeBare.js', 126 | 'test/expected/maps/coffeeBare.js', 127 | 'Bare compilation of single file with source maps should generate javascript'); 128 | 129 | assertFileEquality(test, 130 | 'tmp/maps/coffeeBare.js.map', 131 | 'test/expected/maps/coffeeBare.js.map', 132 | 'Bare compilation of single file with source maps should generate map'); 133 | 134 | assertFileEquality(test, 135 | 'tmp/maps/coffeeBareJoin.js', 136 | 'test/expected/maps/coffeeBareJoin.js', 137 | 'Bare compilation of multiple files with source maps should generate javascript'); 138 | 139 | assertFileEquality(test, 140 | 'tmp/maps/coffeeBareJoin.js.map', 141 | 'test/expected/maps/coffeeBareJoin.js.map', 142 | 'Bare compilation of multiple files with source maps should generate map'); 143 | 144 | assertFileEquality(test, 145 | 'tmp/maps/coffeeBareJoin.src.coffee', 146 | 'test/expected/maps/coffeeBareJoin.src.coffee', 147 | 'Bare compilation of multiple files with source maps should output concatenated source'); 148 | 149 | test.done(); 150 | }, 151 | compileEachMap: function(test) { 152 | test.expect(4); 153 | 154 | assertFileEquality(test, 155 | 'tmp/eachMap/coffee1.js', 156 | 'test/expected/eachMap/coffee1.js', 157 | 'Separate compilation of coffee and litcoffee files with source maps should generate javascript'); 158 | 159 | assertFileEquality(test, 160 | 'tmp/eachMap/litcoffee.js', 161 | 'test/expected/eachMap/litcoffee.js', 162 | 'Separate compilation of coffee and litcoffee files with source maps should generate javascript'); 163 | 164 | assertFileEquality(test, 165 | 'tmp/eachMap/coffee1.js.map', 166 | 'test/expected/eachMap/coffee1.js.map', 167 | 'Separate compilation of coffee and litcoffee files with source maps should generate map'); 168 | 169 | assertFileEquality(test, 170 | 'tmp/eachMap/litcoffee.js.map', 171 | 'test/expected/eachMap/litcoffee.js.map', 172 | 'Separate compilation of coffee and litcoffee files with source maps should generate map'); 173 | 174 | test.done(); 175 | }, 176 | compileSourceMapDir: function(test) { 177 | test.expect(2); 178 | 179 | assertFileEquality(test, 180 | 'tmp/sourceMapDir1/coffee.js', 181 | 'test/expected/sourceMapDir1/coffee.js', 182 | 'Compilation of single file with source maps should generate javascript'); 183 | 184 | assertFileEquality(test, 185 | 'tmp/sourceMapDir2/coffee.js.map', 186 | 'test/expected/sourceMapDir2/coffee.js.map', 187 | 'Compilation of single file with alternate source map dir should generate map'); 188 | 189 | test.done(); 190 | }, 191 | compileNested: function(test) { 192 | test.expect(2); 193 | 194 | assertFileEquality(test, 195 | 'tmp/nest/1/coffee.js.map', 196 | 'test/expected/maps/coffeeNested.js.map', 197 | 'Compilation of nested maps should respect path info'); 198 | 199 | assertFileEquality(test, 200 | 'tmp/nest/2/coffee.js.map', 201 | 'test/expected/maps/coffeeNested.js.map', 202 | 'Compilation of nested maps should change per file'); 203 | 204 | test.done(); 205 | }, 206 | compileMDCoffeeMaps: function(test) { 207 | test.expect(2); 208 | 209 | assertFileEquality(test, 210 | 'tmp/litCoffeeMaps/mdcoffee.js', 211 | 'test/expected/litCoffeeMaps/mdcoffee.js', 212 | 'Compilation of multiple coffee.md files with maps should generate javascript'); 213 | 214 | assertFileEquality(test, 215 | 'tmp/litCoffeeMaps/mdcoffee.js.map', 216 | 'test/expected/litCoffeeMaps/mdcoffee.js.map', 217 | 'Compilation of multiple coffee.md files with maps should generate map'); 218 | 219 | test.done(); 220 | }, 221 | compileLitCoffeeMaps: function(test) { 222 | test.expect(2); 223 | 224 | assertFileEquality(test, 225 | 'tmp/litCoffeeMaps/litcoffee.js', 226 | 'test/expected/litCoffeeMaps/litcoffee.js', 227 | 'Compilation of multiple .litcoffee files with maps should generate javascript'); 228 | 229 | assertFileEquality(test, 230 | 'tmp/litCoffeeMaps/litcoffee.js.map', 231 | 'test/expected/litCoffeeMaps/litcoffee.js.map', 232 | 'Compilation of multiple .litcoffee files with maps should generate map'); 233 | 234 | test.done(); 235 | } 236 | }; 237 | -------------------------------------------------------------------------------- /test/expected/bare/coffee.js: -------------------------------------------------------------------------------- 1 | var HelloWorld; 2 | 3 | HelloWorld = (function() { 4 | class HelloWorld {}; 5 | 6 | HelloWorld.test = 'test'; 7 | 8 | return HelloWorld; 9 | 10 | }).call(this); 11 | -------------------------------------------------------------------------------- /test/expected/bare/concat.js: -------------------------------------------------------------------------------- 1 | var HelloWorld; 2 | 3 | HelloWorld = (function() { 4 | class HelloWorld {}; 5 | 6 | HelloWorld.test = 'test'; 7 | 8 | return HelloWorld; 9 | 10 | }).call(this); 11 | 12 | console.log('hi'); 13 | 14 | // Begin function declaration. 15 | var sayHello; 16 | 17 | sayHello = function() { 18 | // Print a greeting. 19 | return console.log('hi'); 20 | }; 21 | -------------------------------------------------------------------------------- /test/expected/bare/litcoffee.js: -------------------------------------------------------------------------------- 1 | // Begin function declaration. 2 | var sayHello; 3 | 4 | sayHello = function() { 5 | // Print a greeting. 6 | return console.log('hi'); 7 | }; 8 | -------------------------------------------------------------------------------- /test/expected/default/coffee.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var HelloWorld; 3 | 4 | HelloWorld = (function() { 5 | class HelloWorld {}; 6 | 7 | HelloWorld.test = 'test'; 8 | 9 | return HelloWorld; 10 | 11 | }).call(this); 12 | 13 | }).call(this); 14 | -------------------------------------------------------------------------------- /test/expected/default/concat.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var HelloWorld; 3 | 4 | HelloWorld = (function() { 5 | class HelloWorld {}; 6 | 7 | HelloWorld.test = 'test'; 8 | 9 | return HelloWorld; 10 | 11 | }).call(this); 12 | 13 | }).call(this); 14 | 15 | (function() { 16 | console.log('hi'); 17 | 18 | }).call(this); 19 | 20 | (function() { 21 | // Begin function declaration. 22 | var sayHello; 23 | 24 | sayHello = function() { 25 | // Print a greeting. 26 | return console.log('hi'); 27 | }; 28 | 29 | }).call(this); 30 | -------------------------------------------------------------------------------- /test/expected/default/litcoffee.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | // Begin function declaration. 3 | var sayHello; 4 | 5 | sayHello = function() { 6 | // Print a greeting. 7 | return console.log('hi'); 8 | }; 9 | 10 | }).call(this); 11 | -------------------------------------------------------------------------------- /test/expected/eachMap/coffee1.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var HelloWorld; 3 | 4 | HelloWorld = (function() { 5 | class HelloWorld {}; 6 | 7 | HelloWorld.test = 'test'; 8 | 9 | return HelloWorld; 10 | 11 | }).call(this); 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;IAAN,MAAA,WAAA,CAAA;;IACE,UAAC,CAAA,IAAD,GAAO;;;;;AADT", 10 | "sourcesContent": [ 11 | "class HelloWorld\r\n @test: 'test'" 12 | ] 13 | } -------------------------------------------------------------------------------- /test/expected/eachMap/litcoffee.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | // Begin function declaration. 3 | var sayHello; 4 | 5 | sayHello = function() { 6 | // Print a greeting. 7 | return console.log('hi'); 8 | }; 9 | 10 | }).call(this); 11 | 12 | //# sourceMappingURL=litcoffee.js.map 13 | -------------------------------------------------------------------------------- /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": "AAA+B;EAAA;AAAA,MAAA;;EAE3B,QAAA,GAAY,QAAA,CAAA,CAAA,EAAA;;WAIV,OAAO,CAAC,GAAR,CAAa,IAAb;EAJU;AAFe", 10 | "sourcesContent": [ 11 | "Begin function declaration.\r\n\r\n sayHello = ->\r\n\r\nPrint a greeting.\r\n\r\n console.log 'hi'\r\n" 12 | ] 13 | } -------------------------------------------------------------------------------- /test/expected/join/bareJoin.js: -------------------------------------------------------------------------------- 1 | var HelloWorld; 2 | 3 | HelloWorld = (function() { 4 | class HelloWorld {}; 5 | 6 | HelloWorld.test = 'test'; 7 | 8 | return HelloWorld; 9 | 10 | }).call(this); 11 | 12 | console.log('hi'); 13 | -------------------------------------------------------------------------------- /test/expected/join/join.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var HelloWorld; 3 | 4 | HelloWorld = (function() { 5 | class HelloWorld {}; 6 | 7 | HelloWorld.test = 'test'; 8 | 9 | return HelloWorld; 10 | 11 | }).call(this); 12 | 13 | console.log('hi'); 14 | 15 | }).call(this); 16 | -------------------------------------------------------------------------------- /test/expected/litCoffeeMaps/litcoffee.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | // Begin function declaration. 3 | var sayHello; 4 | 5 | sayHello = function() { 6 | // Print a greeting. 7 | return console.log('hi'); 8 | }; 9 | 10 | // Begin function declaration. 11 | sayHello = function() { 12 | // Print a greeting. 13 | return console.log('I like to annotate my source with literated coffee.'); 14 | }; 15 | 16 | }).call(this); 17 | 18 | //# sourceMappingURL=litcoffee.js.map 19 | -------------------------------------------------------------------------------- /test/expected/litCoffeeMaps/litcoffee.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "litcoffee.js", 4 | "sourceRoot": "", 5 | "sources": [ 6 | "litcoffee.src.litcoffee" 7 | ], 8 | "names": [], 9 | "mappings": "AAA+B;EAAA;AAAA,MAAA;;EAE3B,QAAA,GAAY,QAAA,CAAA,CAAA,EAAA;;WAIV,OAAO,CAAC,GAAR,CAAa,IAAb;EAJU,EAFe;;;EAU3B,QAAA,GAAa,QAAA,CAAA,CAAA,EAAA;;WAIX,OAAO,CAAC,GAAR,CAAY,qDAAZ;EAJW;AAVc", 10 | "sourcesContent": [ 11 | "Begin function declaration.\r\n\r\n sayHello = ->\r\n\r\nPrint a greeting.\r\n\r\n console.log 'hi'\r\n\r\nBegin function declaration.\r\n\r\n sayHello = ->\r\n\r\nPrint a greeting.\r\n\r\n console.log 'I like to annotate my source with literated coffee.'\r\n" 12 | ] 13 | } -------------------------------------------------------------------------------- /test/expected/litCoffeeMaps/mdcoffee.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | // Begin function declaration. 3 | var sayHello; 4 | 5 | sayHello = function() { 6 | // Print a greeting. 7 | return console.log('hi'); 8 | }; 9 | 10 | // Begin function declaration. 11 | sayHello = function() { 12 | // Print a greeting. 13 | return console.log('I like to annotate my source with literated coffee.'); 14 | }; 15 | 16 | }).call(this); 17 | 18 | //# sourceMappingURL=mdcoffee.js.map 19 | -------------------------------------------------------------------------------- /test/expected/litCoffeeMaps/mdcoffee.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "mdcoffee.js", 4 | "sourceRoot": "", 5 | "sources": [ 6 | "mdcoffee.src.coffee.md" 7 | ], 8 | "names": [], 9 | "mappings": "AAA+B;EAAA;AAAA,MAAA;;EAE3B,QAAA,GAAY,QAAA,CAAA,CAAA,EAAA;;WAIV,OAAO,CAAC,GAAR,CAAa,IAAb;EAJU,EAFe;;;EAU3B,QAAA,GAAa,QAAA,CAAA,CAAA,EAAA;;WAIX,OAAO,CAAC,GAAR,CAAY,qDAAZ;EAJW;AAVc", 10 | "sourcesContent": [ 11 | "Begin function declaration.\r\n\r\n sayHello = ->\r\n\r\nPrint a greeting.\r\n\r\n console.log 'hi'\r\n\r\nBegin function declaration.\r\n\r\n sayHello = ->\r\n\r\nPrint a greeting.\r\n\r\n console.log 'I like to annotate my source with literated coffee.'\r\n" 12 | ] 13 | } -------------------------------------------------------------------------------- /test/expected/maps/coffee.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var HelloWorld; 3 | 4 | HelloWorld = (function() { 5 | class HelloWorld {}; 6 | 7 | HelloWorld.test = 'test'; 8 | 9 | return HelloWorld; 10 | 11 | }).call(this); 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;IAAN,MAAA,WAAA,CAAA;;IACE,UAAC,CAAA,IAAD,GAAO;;;;;AADT", 10 | "sourcesContent": [ 11 | "class HelloWorld\r\n @test: 'test'" 12 | ] 13 | } -------------------------------------------------------------------------------- /test/expected/maps/coffeeBare.js: -------------------------------------------------------------------------------- 1 | var HelloWorld; 2 | 3 | HelloWorld = (function() { 4 | class HelloWorld {}; 5 | 6 | HelloWorld.test = 'test'; 7 | 8 | return HelloWorld; 9 | 10 | }).call(this); 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;EAAN,MAAA,WAAA,CAAA;;EACE,UAAC,CAAA,IAAD,GAAO", 10 | "sourcesContent": [ 11 | "class HelloWorld\r\n @test: 'test'" 12 | ] 13 | } -------------------------------------------------------------------------------- /test/expected/maps/coffeeBareJoin.js: -------------------------------------------------------------------------------- 1 | var HelloWorld; 2 | 3 | HelloWorld = (function() { 4 | class HelloWorld {}; 5 | 6 | HelloWorld.test = 'test'; 7 | 8 | return HelloWorld; 9 | 10 | }).call(this); 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;EAAN,MAAA,WAAA,CAAA;;EACE,UAAC,CAAA,IAAD,GAAO;;;;;;AACT,OAAO,CAAC,GAAR,CAAY,IAAZ", 10 | "sourcesContent": [ 11 | "class HelloWorld\r\n @test: 'test'\r\nconsole.log('hi')" 12 | ] 13 | } -------------------------------------------------------------------------------- /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 | class HelloWorld {}; 6 | 7 | HelloWorld.test = 'test'; 8 | 9 | return HelloWorld; 10 | 11 | }).call(this); 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;IAAN,MAAA,WAAA,CAAA;;IACE,UAAC,CAAA,IAAD,GAAO;;;;;;EACT,OAAO,CAAC,GAAR,CAAY,IAAZ;AAFA", 10 | "sourcesContent": [ 11 | "class HelloWorld\r\n @test: 'test'\r\nconsole.log('hi')" 12 | ] 13 | } -------------------------------------------------------------------------------- /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;IAAN,MAAA,WAAA,CAAA;;IACE,UAAC,CAAA,IAAD,GAAO;;;;;AADT", 10 | "sourcesContent": [ 11 | "class HelloWorld\n @test: 'test'" 12 | ] 13 | } -------------------------------------------------------------------------------- /test/expected/sourceMapDir1/coffee.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var HelloWorld; 3 | 4 | HelloWorld = (function() { 5 | class HelloWorld {}; 6 | 7 | HelloWorld.test = 'test'; 8 | 9 | return HelloWorld; 10 | 11 | }).call(this); 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;IAAN,MAAA,WAAA,CAAA;;IACE,UAAC,CAAA,IAAD,GAAO;;;;;AADT", 10 | "sourcesContent": [ 11 | "class HelloWorld\r\n @test: 'test'" 12 | ] 13 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/fixtures/litcoffee1.litcoffee: -------------------------------------------------------------------------------- 1 | Begin function declaration. 2 | 3 | sayHello = -> 4 | 5 | Print a greeting. 6 | 7 | console.log 'I like to annotate my source with literated coffee.' 8 | -------------------------------------------------------------------------------- /test/fixtures/mdcoffee.coffee.md: -------------------------------------------------------------------------------- 1 | Begin function declaration. 2 | 3 | sayHello = -> 4 | 5 | Print a greeting. 6 | 7 | console.log 'hi' 8 | -------------------------------------------------------------------------------- /test/fixtures/mdcoffee1.coffee.md: -------------------------------------------------------------------------------- 1 | Begin function declaration. 2 | 3 | sayHello = -> 4 | 5 | Print a greeting. 6 | 7 | console.log 'I like to annotate my source with literated coffee.' 8 | --------------------------------------------------------------------------------