grunt-autowrap

grunt task plugin auto wrap exports or amd for js or coffee

grunt-autowrap

auto exports wrap for js or coffee (currently exports based on filenames)

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');

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'],
        },
      },
    },
})

Type: boolean Default value: false

exports symbol.

Type: boolean Default value: false

concatenate files before processing.

Type: boolean Default value: false

add a wrapper function.

Type: String Default value: js

source file extension.

Type: boolean Default value: false

compile coffee.

Type: String Default value: "\n"

separator used to join 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'],
      },
    },
  },
})
grunt.initConfig({
  autowrap: {
    testCoffee:{
      options: {
        exports:true,
        join: true,
        wrap:true,
        ext: 'coffee',
        coffee:true,
      },
      files: {
        'tmp/testCoffee.js': ['test/fixtures/*.coffee'],
      },
    },
  },
})

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.

0.1.0 exports based on filename