grunt-autowrap v0.3.0
grunt-autowrap
auto exports wrap for js or coffee (currently exports based on filenames)
Getting Started
This plugin requires Grunt ~0.4.1
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-autowrap --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-autowrap');
The "autowrap" task
Overview
In your project's Gruntfile, add a section named autowrap
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
autowrap: {
testJs:{
options: {
exports:true,
join: true,
wrap: true,
ext: 'js',
},
files: {
'tmp/testJs.js': ['test/fixtures/A.js', 'test/fixtures/B.js'],
},
},
testCoffee:{
options: {
exports:true,
join: true,
wrap:true,
ext: 'coffee',
coffee:true,
},
files: {
'tmp/testCoffee.js': ['test/fixtures/*.coffee'],
},
},
},
})
Options
options.exports
Type: boolean
Default value: false
exports symbol.
options.join
Type: boolean
Default value: false
concatenate files before processing.
options.wrap
Type: boolean
Default value: false
add a wrapper function.
options.ext
Type: String
Default value: js
source file extension.
options.coffee
Type: boolean
Default value: false
compile coffee.
options.separator
Type: String
Default value: "\n"
separator used to join files.
Usage Examples
exports concat and wrap js files
grunt.initConfig({
autowrap: {
testJs:{
options: {
exports:true,
join: true,
wrap: true,
ext: 'js',
},
files: {
'tmp/testJs.js': ['test/fixtures/A.js', 'test/fixtures/B.js'],
},
},
},
})
exports and wrap coffee files
grunt.initConfig({
autowrap: {
testCoffee:{
options: {
exports:true,
join: true,
wrap:true,
ext: 'coffee',
coffee:true,
},
files: {
'tmp/testCoffee.js': ['test/fixtures/*.coffee'],
},
},
},
})
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
Release History
0.1.0 exports based on filename