Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grunt-contrib-coffee

Package Overview
Dependencies
Maintainers
5
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-contrib-coffee - npm Package Compare versions

Comparing version 0.3.2 to 0.4.0-rc7

.jshintrc

16

package.json
{
"name": "grunt-contrib-coffee",
"description": "Compile CoffeeScript files to JavaScript.",
"version": "0.3.2",
"version": "0.4.0rc7",
"homepage": "https://github.com/gruntjs/grunt-contrib-coffee",

@@ -23,5 +23,5 @@ "author": {

],
"main": "grunt.js",
"main": "Gruntfile.js",
"engines": {
"node": "*"
"node": ">= 0.8.0"
},

@@ -32,8 +32,10 @@ "scripts": {

"dependencies": {
"coffee-script": "~1.3.3",
"grunt-lib-contrib": "~0.3.0"
"coffee-script": "~1.4"
},
"devDependencies": {
"grunt": "~0.3.15",
"grunt-contrib-clean": "~0.3.0"
"grunt-contrib-jshint": "0.1.1rc6",
"grunt-contrib-nodeunit": "0.1.2rc6",
"grunt-contrib-clean": "0.4.0rc6",
"grunt-contrib-internal": "*",
"grunt": "0.4.0rc7"
},

@@ -40,0 +42,0 @@ "keywords": [

@@ -5,37 +5,38 @@ # grunt-contrib-coffee [![Build Status](https://secure.travis-ci.org/gruntjs/grunt-contrib-coffee.png?branch=master)](http://travis-ci.org/gruntjs/grunt-contrib-coffee)

### Overview
Inside your `grunt.js` file add a section named `coffee`. This section specifies the files to compile and the options passed to [CoffeeScript](http://coffeescript.org/#usage).
## Getting Started
If you haven't used [grunt][] before, be sure to check out the [Getting Started][] guide, as it explains how to create a [gruntfile][Getting Started] as well as install and use grunt plugins. Once you're familiar with that process, install this plugin with this command:
#### Parameters
```shell
npm install grunt-contrib-coffee --save-dev
```
##### files ```object```
[grunt]: http://gruntjs.com/
[Getting Started]: https://github.com/gruntjs/grunt/blob/devel/docs/getting_started.md
This defines what files this task will process and should contain key:value pairs.
The key (destination) should be an unique filepath (supports [grunt.template](https://github.com/gruntjs/grunt/blob/master/docs/api_template.md)) and the value (source) should be a filepath or an array of filepaths (supports [minimatch](https://github.com/isaacs/minimatch)).
## Coffee task
_Run this task with the `grunt coffee` command._
As of v0.3.0, you can use *.{ext} as your destination filename to individually compile each file to the destination directory. Otherwise, when the source contains an array of multiple filepaths, the contents are concatenated in the order passed.
_This task is a [multi task][] so any targets, files and options should be specified according to the [multi task][] documentation._
[multi task]: https://github.com/gruntjs/grunt/wiki/Configuring-tasks
##### options ```object```
This controls how this task (and its helpers) operate and should contain key:value pairs, see options below.
_Version `0.4.x` of this plugin is compatible with Grunt `0.4.x`. Version `0.3.x` of this plugin is compatible with Grunt `0.3.x`._
#### Options
### Options
##### bare ```boolean```
#### separator
Type: `String`
Default: linefeed
Compile the JavaScript without the top-level function safety wrapper.
Concatenated files will be joined on this string.
##### basePath ```string``` (individual only)
#### bare
Type: `boolean`
This option adjusts the folder structure when compiled to the destination directory. When not explicitly set, best effort is made to locate the basePath by comparing all source filepaths left to right for a common pattern.
Compile the JavaScript without the top-level function safety wrapper.
### Usage Examples
##### flatten ```boolean``` (individual only)
This option performs a flat compile that dumps all the files into the root of the destination directory, overwriting files if they exist.
#### Config Example
``` javascript
```js
coffee: {

@@ -45,19 +46,30 @@ compile: {

'path/to/result.js': 'path/to/source.coffee', // 1:1 compile
'path/to/another.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'], // compile and concat into single file
'path/to/*.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // compile individually into dest, maintaining folder structure
'path/to/another.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // compile and concat into single file
}
},
glob_to_multiple: {
files: grunt.file.expandMapping(['path/to/*.coffee'], 'path/to/dest/', {
rename: function(destBase, destPath) {
return destBase + destPath.replace(/\.coffee$/, '.js');
}
},
flatten: {
options: {
flatten: true
},
files: {
'path/to/*.js': ['path/to/sources/*.coffee', 'path/to/more/*.coffee'] // compile individually into dest, flattening folder structure
}
}
})
}
}
```
--
## Release History
*Task submitted by [Eric Woroshow](https://github.com/errcw).*
* 2013-01-22   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.
* 2013-01-08   v0.4.0rc5   Updating to work with grunt v0.4.0rc5. Switching to this.filesSrc api.
* 2012-12-14   v0.4.0a   Conversion to grunt v0.4 conventions. Remove experimental destination wildcards.
* 2012-10-11   v0.3.2   Rename grunt-contrib-lib dep to grunt-lib-contrib.
* 2012-09-24   v0.3.1   Don't fail when there are no files.
* 2012-09-23   v0.3.0   Global options depreciated.
* 2012-09-09   v0.2.0   Refactored from grunt-contrib into individual repo.
---
Task submitted by [Eric Woroshow](http://ericw.ca/)
*This file was generated on Wed Jan 23 2013 10:22:24.*

@@ -12,56 +12,34 @@ /*

// TODO: ditch this when grunt v0.4 is released
grunt.util = grunt.util || grunt.utils;
grunt.registerMultiTask('coffee', 'Compile CoffeeScript files into JavaScript', function() {
var path = require('path');
var helpers = require('grunt-lib-contrib').init(grunt);
var options = helpers.options(this, {
var options = this.options({
bare: false,
basePath: false,
flatten: false
separator: grunt.util.linefeed
});
if (options.basePath || options.flatten) {
grunt.fail.warn('Experimental destination wildcards are no longer supported. please refer to README.');
}
grunt.verbose.writeflags(options, 'Options');
// TODO: ditch this when grunt v0.4 is released
this.files = this.files || helpers.normalizeMultiTaskFiles(this.data, this.target);
var basePath;
var newFileDest;
var srcFiles;
var srcCompiled;
var taskOutput;
this.files.forEach(function(file) {
file.dest = path.normalize(file.dest);
srcFiles = grunt.file.expandFiles(file.src);
if (srcFiles.length === 0) {
grunt.log.writeln('Unable to compile; no valid source files were found.');
return;
}
taskOutput = [];
srcFiles.forEach(function(srcFile) {
srcCompiled = compileCoffee(srcFile, options);
if (helpers.isIndividualDest(file.dest)) {
basePath = helpers.findBasePath(srcFiles, options.basePath);
newFileDest = helpers.buildIndividualDest(file.dest, srcFile, basePath, options.flatten);
grunt.file.write(newFileDest, srcCompiled || '');
grunt.log.writeln('File ' + newFileDest.cyan + ' created.');
this.files.forEach(function(f) {
var output = f.src.filter(function(filepath) {
// Warn on and remove invalid source files (if nonull was set).
if (!grunt.file.exists(filepath)) {
grunt.log.warn('Source file "' + filepath + '" not found.');
return false;
} else {
taskOutput.push(srcCompiled);
return true;
}
});
}).map(function(filepath) {
return compileCoffee(filepath, options);
}).join(grunt.util.normalizelf(options.separator));
if (taskOutput.length > 0) {
grunt.file.write(file.dest, taskOutput.join('\n') || '');
grunt.log.writeln('File ' + file.dest.cyan + ' created.');
if (output.length < 1) {
grunt.log.warn('Destination not written because compiled files were empty.');
} else {
grunt.file.write(f.dest, output);
grunt.log.writeln('File ' + f.dest + ' created.');
}

@@ -73,4 +51,2 @@ });

options = grunt.util._.extend({filename: srcFile}, options);
delete options.basePath;
delete options.flatten;

@@ -77,0 +53,0 @@ var srcCode = grunt.file.read(srcFile);

var grunt = require('grunt');
var fs = require('fs');
function readFile(file) {
'use strict';
var contents = grunt.file.read(file);
if (process.platform === 'win32') {
contents = contents.replace(/\r\n/g, '\n');
}
return contents;
}
exports.coffee = {

@@ -8,29 +20,14 @@ compile: function(test) {

test.expect(3);
test.expect(2);
var actual = grunt.file.read('tmp/coffee.js');
var expected = grunt.file.read('test/expected/coffee.js');
var actual = readFile('tmp/coffee.js');
var expected = readFile('test/expected/coffee.js');
test.equal(expected, actual, 'should compile coffeescript to javascript');
actual = grunt.file.read('tmp/concat.js');
expected = grunt.file.read('test/expected/concat.js');
actual = readFile('tmp/concat.js');
expected = readFile('test/expected/concat.js');
test.equal(expected, actual, 'should compile multiple coffeescript files to a single javascript file');
actual = fs.readdirSync('tmp/individual').sort();
expected = fs.readdirSync('test/expected/individual').sort();
test.deepEqual(expected, actual, 'should individually compile files');
test.done();
},
flatten: function(test) {
'use strict';
test.expect(1);
var actual = fs.readdirSync('tmp/individual_flatten').sort();
var expected = fs.readdirSync('test/expected/individual_flatten').sort();
test.deepEqual(expected, actual, 'should individually compile files (to flat structure)');
test.done();
}
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc