{"_id":"grunt-hug","_rev":"85-b00dbd0649e116b0f00946cd6f0ee249","name":"grunt-hug","description":"Concatinate your web application without worrying about the order of your files.","dist-tags":{"latest":"0.5.2"},"versions":{"0.2.3":{"name":"grunt-hug","description":"Scopes your variable declarations to the file they're declared in and then concatenates files with dependency resolution.","version":"0.2.3","homepage":"https://github.com/ozanturgut/grunt-hug","author":{"name":"Ozan Turgut","url":"http://oztu.org/"},"repository":{"type":"git","url":"git://github.com/ozanturgut/grunt-hug.git"},"bugs":{"url":"https://github.com/ozanturgut/grunt-hug/issues"},"licenses":[{"type":"MIT","url":"https://github.com/ozanturgut/grunt-hug/blob/master/LICENSE-MIT"}],"main":"grunt.js","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test"},"dependencies":{},"devDependencies":{"grunt-contrib-clean":"~0.3.0","grunt":"~0.3.11"},"keywords":["gruntplugin"],"readme":"# grunt-hug [![Build Status](https://secure.travis-ci.org/ozanturgut/grunt-hug.png?branch=master)](http://travis-ci.org/ozanturgut/grunt-hug)\n\nHug makes developing web applications easier. You provide a directory, grunt generates one combined file, performing dependency resolution along the way. It's like concat, except you don't have to worry about the order of your files. It also keeps your namespaces clean by limiting the scope of variable declarations to file-level by wrapping each file in an anonymous self-executing function.\n\n## Why Hugging Will Make You Happy\n\n* You provide a root directory, grunt figures out how to concatinate your files to fulfill dependency constraints.\n* Your file-level variables declarations will actually be scoped at file-level (they won't leak to the environment).\n* It'll make your minified files smaller because it explicitly defines what the external api will be (and therefore anything not in the external api can be safely renamed to something shorted during minifaction).\n* You can `require([relativePath])` other files to bring them into the current scope.\n* You can optionally generate one variable encompasing your entire API.\n\n## Target Audience\n\nHugging occurs at build-time, so an application which needs to load it's dependencies at runtime (lazy loading) won't benefit much from hugging -- you'll likely prefer the likes of [RequireJS](http://requirejs.org/). \n\nFor frameworks or compiled applications, hugging is awesome. Your code will be clean, safe, and boiler-plate-free. As an added benefit, your unhugged code will work in nodejs applications so long as you're not using any browser-specific functions.\n\n## Importing libraries\nYou likely depend on external libraries. Here two approaches you can take to import import them into Hug:\n* Some libraries automatically bind to an exports variable if it exists (ex: jQuery, Underscore), these can be treated like any other file in your package by using ```require()``` to bring them in to scope.\n* Libraries which declare a var or introduce a global variable can be added to the ```header``` of the package. The header is prepended to the package and the entire package is wrapped in an anonymous function, so if all the library does is declare variables, those variables will become package-level variables.\n\n## Simple Example\nSay I have two files:\n``` javascript\n// file1.js \nexports.word1 = \"hello\";\nexports.word2 = \"world\";\n```\n``` javascript\n// file2.js\nvar file1Exports = require('./file1.js');\nconsole.log(file1Exports.word1 + \" \" + file1Exports.word2);\n```\nWhen these files run through hug, this will be the generated file:\n``` javascript\n(function(){\n\tvar __module0 = (function(){\n\t\tvar module = {};\n\t\tvar exports = module.exports = {};\n\t\t\n\t\texports.word1 = \"hello\";\n\t\texports.word2 = \"world\";\n\t\t\n\t\treturn module.exports || exports;\n\t}());\n\t\n\tvar __module1 = (function(){\n\t\tvar module = {};\n\t\tvar exports = module.exports = {};\n\t\n\t\tvar file1Exports = __module0;\n\t\tconsole.log(file1Exports.word1 + \" \" + file1Exports.word2);\n\t\t\n\t\treturn module.exports || exports;\n\t}());\n\t\n\treturn {\"file1\":__module0,\"file2\":__module1};\n}());\n```\n\n## Complex Example\n\nSay I have the following file structure:\n```\nsrc/\n    language/\n        message/\n                aSaying.js\n        words.js\n        speaker.js\n    init.js\ngrunt.js\n```\n\nWith the following file contents:\n\n``` javascript\n// src/init.js\nvar theMessage = require('language/message/aSaying.js').whatTheySay;\nconsole.log(theMessage);\n```\n\n``` javascript\n// src/language/message/aSaying.js\nvar theWord = require('../words.js').aWord;\nvar speaker = require('../speaker.js');\n\nexports.whatTheySay = speaker(theWord);\n```\n\n``` javascript\n// src/language/words.js\nexports.aWord = \"world\";\n````\n\n``` javascript\n// src/language/speaker.js\nexports = function(anything){\n\treturn \"Hello, \" + anything + \"!\";\n};\n```\n\n``` javascript\n// grunt.js\n// ...other config stuff...\n// in the object passed into initConfig:\nhug: {\n\tdist: {\n\t\tsrc: 'src',\n\t\tdest: 'build/hi.js'\n\t}\n}\n// ...other config stuff...\n```\n\nWhen grunt is asked to hug this source tree, it'll concatinate the files in order of dependencies, and wrap each file in an anonymous function, and match up dependencies.\n\nRunning `hi.js` will output \"Hello, world!\" on the console, with no trace of the program ever running (nothing leaked to the global scope).\n\n## Usage\n\nInside your `grunt.js` file, in the object you pass to initConfig, add a section named `hug`. Inside this section, add 1 or more subsections for different `hug` tasks.\n\n#### Parameters\n\n##### src ```string```\n\nThis defines the root directory of your source tree. Any JS file under this directory will become part of the generated file.\n\n##### dest ```string```\n\nThis defines what the path for the generated file should be. Grunt will automatically generate directories if they don't exit.\n\n##### (optional) header ```file list```\n\nA list of files to prepend to the package. These files are not wrapped in anonymous functions, so any variables that are declared will be visible to the entire package. This is a good choice for utility functions or libraries which don't support exporting their variables.\n\n##### (optional) exportsVariable ```string```\n\nThis is an optional parameter. If provided, the generated file will produce a global variable with the given name holding the export tree. For example, if we had set `exportsVariable: 'hugExample'` for the example above, and ran the generated script, we would end up with a global variable like this:\n\n``` javascript\nconsole.log(hugExample);\n// Output:\n//\thugExample: {\n//\t\tlanguage: {\n//\t\t\tmessage: {\n//\t\t\t\taSaying: {\n//\t\t\t\twhatTheySay: 'Hello, world!'\n//\t\t\t},\n//\t\t\twords: {\n//\t\t\t\taWord: \"world\"\n//\t\t\t},\n//\t\t\tspeaker: function(anything){return \"Hello, \" + anything + \"!\";}\n//\t\t},\n//\t\tinit: {}\n//\t}\n```\nNote that you can't use the exportsVariable in the source code, you have to use the `require` method to access the exports of other files.\n\n## Known Limitations and Possibilities\n* You cannot `require` a file outside of your source tree. For third-party libraries use grunt `concat` to concatinate them ahead of the hug generated file. You'll also likely want to minify the generated file.\n* You can set `exportsVariable` to `exports` and use the generated file in another source tree (which can then also be hugged) as a way to cleanly encapsulate your APIs.\n\n","_id":"grunt-hug@0.2.3","dist":{"shasum":"5b4c903ef6bb65dd7329b5d098110d3f7e9d328b","tarball":"https://registry.npmjs.org/grunt-hug/-/grunt-hug-0.2.3.tgz","integrity":"sha512-0w0dw8D47vcF7stHuuIMnWorryfo0uY9Twe5kD9nIKgYk+iSXslFjEWv9g8qNPDLshacldWdvdvasYDomTIHWA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICRWjkRLo/T6eULMyYPSXjj5p4iUlbiIHTPoKBdkeMkvAiBq87AwGAxZuN7yZYdjgOw+39eemJeEEcF/7HjGNd8eQg=="}]},"_npmVersion":"1.1.59","_npmUser":{"name":"ozanturgut","email":"ozanturgut@gmail.com"},"maintainers":[{"name":"ozanturgut","email":"ozanturgut@gmail.com"}],"directories":{}},"0.3.0":{"name":"grunt-hug","description":"Concatinate your web application without worrying about the order of your files.","version":"0.3.0","homepage":"https://github.com/ozanturgut/grunt-hug","author":{"name":"Ozan Turgut","url":"http://oztu.org/"},"repository":{"type":"git","url":"git://github.com/ozanturgut/grunt-hug.git"},"bugs":{"url":"https://github.com/ozanturgut/grunt-hug/issues"},"licenses":[{"type":"Apache License 2.0","url":"https://github.com/ozanturgut/grunt-hug/blob/master/LICENSE-APACHE2"}],"main":"grunt.js","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test"},"dependencies":{},"devDependencies":{"grunt":"~0.3.15","grunt-contrib-clean":"~0.3.1","mocks":"~0.0.10","sinon":"~1.5.2"},"keywords":["gruntplugin"],"readme":"# grunt-hug [![Build Status](https://secure.travis-ci.org/ozanturgut/grunt-hug.png?branch=master)](http://travis-ci.org/ozanturgut/grunt-hug)\r\n\r\nHug makes maintaining and packaging web applications easier, it is a [grunt](http://gruntjs.com) plugin. \r\nTell it how to find your files and it will concatinate them in the right order of dependencies. \r\nIt will also prevent accidental variable leakage between files by wrapping each file in a self-executing \r\nanonymous function.\r\n\r\n## Why Hugging Will Make You Happy\r\n\r\n* **Automated dependency resolution.** It will figure out the required order for your files when concatinating.\r\n* **File-level variables** declarations won't leak to the environment and will remain at file-level.\r\n* Allows you to **define an API** for the package which can be used by other applications.\r\n\r\n## Target Audience\r\n\r\nHugging occurs at build-time, so an application which needs to load it's dependencies at runtime (lazy loading) \r\nwon't benefit much from hugging -- you'll likely prefer [RequireJS](http://requirejs.org/). \r\n\r\nFor frameworks or compiled applications, hugging is awesome. Your code will be clean, safe, and boiler-plate-free. \r\nAs an added benefit, your unhugged code will work in nodejs applications so long as you're not using any \r\nbrowser-specific functions (for example, `alert`).\r\n\r\n## How to Hug\r\n\r\n* Define the variables that a file will expose by assigning them to the `exports` variable. An example:\r\n`exports.numbers = [1,2,3];`.\r\n* Retrieve the exports of another file by using the `require` function. An example:  \r\n`var fileExports = require(\"[A RELATIVE PATH]\")`. \r\n\r\nIf you want to assign something as the exports object itself, assign it to `module.exports`. Assigning anything\r\ndirectly to `exports` would replace the object pointer entirely. If you've done nodejs programming \r\nbefore, you should already be used to this, just remember you can't import npm packages like \r\nyou can in node -- currently, hug only imports from relative file paths.\r\n\r\n## A Simple Example\r\nSay I have two files:\r\n```javascript\r\n// required.js \r\nexports.message = \"Hello, world!\";\r\n```\r\n\r\n```javascript\r\n// requiree.js\r\nvar otherFile = require('required.js');\r\nalert(otherFile.message);\r\n```\r\n\r\n```javascript\r\n// grunt.js\r\nmodule.exports = function(grunt){\r\n grunt.initConfig({\r\n \thug: {\r\n \t\tsimple: {\r\n \t\t\tsrc: \"./example/simple/**/*\",\r\n \t\t\tdest: \"./tmp/simple-example.js\"\r\n \t\t}\r\n \t}\r\n });\r\n}\r\n```\r\n\r\nWhen we run `grunt hug`, simple-example.js is generated. When simple-example.js runs in a browser, \r\nit will alert \"Hello, world!\". Note that the window object is never touched, the entire application \r\nis within a closure, it leaves no trace after it's run. Here is the file itself:\r\n\r\n```javascript\r\n// simple-example.js\r\n(function(){\r\n\tvar __m0=(function(module,exports){module.exports=exports;\r\n\t\texports.message = \"Hello, world!\";\r\n\t\t;return module.exports;\r\n\t}({},{}));\r\n\r\n\tvar __m1=(function(module,exports){module.exports=exports;\r\n\t\tvar otherFile = __m0;\r\n\r\n\t\talert(otherFile.message);\r\n\t\t;return module.exports;\r\n\t}({},{}));\r\n}());\r\n```\r\n\r\n## A More Complex Example\r\n\r\nSay I have the following file structure:\r\n```javascript\r\nsrc/\r\n    language/\r\n        message/\r\n                aSaying.js\r\n        composer.js\r\n        words.js\r\n    exports.js\r\n    speak.js\r\ngrunt.js\r\n```\r\n\r\nWith the following file contents:\r\n\r\n```javascript\r\n// src/language/message/aSaying.js\r\nvar theWord = require('../words.js').aWord;\r\nvar composer = require('../composer.js');\r\n\r\nexports.whatTheySay = composer(theWord);\r\n```\r\n\r\n```javascript\r\n// src/language/composer.js\r\nexports = function(anything){\r\n\treturn \"Hello, \" + anything + \"!\";\r\n};\r\n```\r\n\r\n```javascript\r\n// src/language/words.js\r\nexports.aWord = \"world\";\r\n```\r\n\r\n```javascript\r\n// src/exports.js\r\nexports.speak = require('./speak.js');\r\nexports.message = require('./language/message/aSaying.js').whatTheySay;\r\n```\r\n\r\n```javascript\r\n// src/speak.js\r\nvar theMessage = require('./language/message/aSaying.js').whatTheySay;\r\nmodule.exports = function(){\r\n\talert(theMessage);\r\n};\r\n```\r\n\r\n```javascript\r\n// grunt.js\r\n// ...other config stuff...\r\n// in the object passed into initConfig:\r\nhug: {\r\n\tadvanced: {\r\n      \t\tsrc: \"./src/**/*\",\r\n        \tdest: \"./tmp/advanced-example.js\",\r\n        \texportedVariable: \"myApi\",\r\n        \texports: \"./src/exports.js\"\r\n\t},\r\n}\r\n// ...other config stuff...\r\n```\r\n\r\nWhen grunt is asked to hugs these files, it'll concatinate the files in order of dependencies, \r\nwrap each file in an anonymous function, and match up dependencies.\r\n\r\nRunning `advanced-example.js` will create an object named `myApi` in the `window` object with the two variables\r\ndefined in exports.js as it's members. Running `myApi.speak()` will alert \"Hello, world\" in a browser.\r\n\r\n## Usage\r\n\r\n**If you've never used grunt before, you will find it very useful to review the \r\n[Getting Started](https://github.com/gruntjs/grunt/blob/0.3-stable/docs/getting_started.md) documentation.**\r\n\r\nInside your `grunt.js` file, in the object you pass to initConfig, add an object named `hug`. \r\nInside this object, add one or more objects for different `hug` tasks.\r\n\r\n#### Parameters\r\n\r\n##### src `String or Array`\r\n\r\nOne or more comma separated wildcard patterns as well as an array of wildcard patterns. These files define the source\r\ncode of your package. Which will be concatinated together.\r\n\r\n##### dest `String`\r\n\r\nThe path for the generated file. Grunt will automatically generate directories if they don't exit.\r\n\r\n##### (optional) exports `String`\r\n\r\nA path to a file to use as the exports object for the package. Whatever the file exports, will be exported by the entire\r\npackage. In essence, this file should define the external api of your package.\r\n\r\n##### (optional) exportedVariable `String` (defaults to \"exports\")\r\n\r\nIf exports is defined, this will be the variable exported to the environment. Whatever the `exports` file exports \r\nwill be assigned to this variable. By setting the value of this to \"module.exports\" you can create a package that\r\ncan be imported by other hug or nodejs applications.\r\n\r\n##### (optional & advanced) moduleVariableName `String` (defaults to \"module\")\r\n\r\nSetting this parameter will break compatibility with importable nodejs modules.\r\nThis parameter allows you to overwrite the variable name used to refer to modules internally. This is useful if\r\nyou already use the `module` variable for something else.\r\n\r\n##### (optional & advanced) exportsVariableName `String` (defaults to \"exports\")\r\n\r\nSetting this parameter will break compatibility with importable nodejs modules.\r\nThis parameter allows you to overwrite the variable name used to refer to exports internally. This is useful if\r\nyou already use the `exports` variable for something else.\r\n\r\n##### (optional & advanced) requireFunctionName `String` (defaults to \"require\")\r\n\r\nSetting this parameter will break compatibility with importable nodejs modules.\r\nThis parameter allows you to overwrite the variable name used to refer to the require function. \r\nThis is useful if you already use the `require` variable for something else.\r\n\r\n## Importing libraries\r\nWeb frameworks and applications that can normally be imported into nodejs applications work as intended.\r\nFor example, you can just `require` the underscore library file and use it as you would normally.\r\n\r\nLibraries which aren't node-friendly can be made importable without modifying the original file by adding an\r\n'adapter' file. Here's an example on how to make jQuery importable:\r\n\r\n```javascript\r\n// jquery-module.js\r\nrequire('./jquery.js');\r\nmodule.exports = window.jQuery;\r\njQuery.noConflict();\r\n```\r\n\r\nFirst we require the actual library so that it gets included in our package and so that it's evaluated before\r\nthis file. Then we export out the reference to jQuery. Finally, we call jQuery.noConflict() which returns the\r\njQuery window variable to it's previous owner (but our exports still points to the one we want).\r\n\r\nNow we can import jquery in other files like so: `var $ = require('./jquery-module.js');`.\r\n\r\n","_id":"grunt-hug@0.3.0","dist":{"shasum":"f76a530051b7f11cfd8037311ab55fd9d61af068","tarball":"https://registry.npmjs.org/grunt-hug/-/grunt-hug-0.3.0.tgz","integrity":"sha512-qbS8okqmiwm17RTaKRtZ7IvNjmxEtLCJhRFOLz9BiYCnyTAYt2DivFIFm846a0Su3xpgj3efHDZl3xKu7pcuOw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCT2D59ep9qEMnB3Mz8vwXp+0T6SZildLIhZ+jY352UxAIhAJV4hHlS9TjPajwb67waeijwnCuypBxnBDr8nVW1L+Uu"}]},"_npmVersion":"1.1.59","_npmUser":{"name":"ozanturgut","email":"ozanturgut@gmail.com"},"maintainers":[{"name":"ozanturgut","email":"ozanturgut@gmail.com"}],"directories":{}},"0.3.1":{"name":"grunt-hug","description":"Concatinate your web application without worrying about the order of your files.","version":"0.3.1","homepage":"https://github.com/ozanturgut/grunt-hug","author":{"name":"Ozan Turgut","url":"http://oztu.org/"},"repository":{"type":"git","url":"git://github.com/ozanturgut/grunt-hug.git"},"bugs":{"url":"https://github.com/ozanturgut/grunt-hug/issues"},"licenses":[{"type":"Apache License 2.0","url":"https://github.com/ozanturgut/grunt-hug/blob/master/LICENSE-APACHE2"}],"main":"grunt.js","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test"},"dependencies":{},"devDependencies":{"grunt":"~0.3.15","grunt-contrib-clean":"~0.3.1","mocks":"~0.0.10","sinon":"~1.5.2"},"keywords":["gruntplugin"],"readme":"# grunt-hug [![Build Status](https://secure.travis-ci.org/ozanturgut/grunt-hug.png?branch=master)](http://travis-ci.org/ozanturgut/grunt-hug)\r\n\r\nHug makes maintaining and packaging web applications easier, it is a [grunt](http://gruntjs.com) plugin. \r\nTell it how to find your files and it will concatinate them in the right order of dependencies. \r\nIt will also prevent accidental variable leakage between files by wrapping each file in a self-executing \r\nanonymous function.\r\n\r\n## Why Hugging Will Make You Happy\r\n\r\n* **Automated dependency resolution.** It will figure out the required order for your files when concatinating.\r\n* **File-level variables** declarations won't leak to the environment and will remain at file-level.\r\n* Allows you to **define an API** for the package which can be used by other applications.\r\n\r\n## Target Audience\r\n\r\nHugging occurs at build-time, so an application which needs to load it's dependencies at runtime (lazy loading) \r\nwon't benefit much from hugging -- you'll likely prefer [RequireJS](http://requirejs.org/). \r\n\r\nFor frameworks or compiled applications, hugging is awesome. Your code will be clean, safe, and boiler-plate-free. \r\nAs an added benefit, your unhugged code will work in nodejs applications so long as you're not using any \r\nbrowser-specific functions (for example, `alert`).\r\n\r\n## How to Hug\r\n\r\n* Define the variables that a file will expose by assigning them to the `exports` variable. An example:\r\n`exports.numbers = [1,2,3];`.\r\n* Retrieve the exports of another file by using the `require` function. An example:  \r\n`var fileExports = require(\"[A RELATIVE PATH]\")`. \r\n\r\nIf you want to assign something as the exports object itself, assign it to `module.exports`. Assigning anything\r\ndirectly to `exports` would replace the object pointer entirely. If you've done nodejs programming \r\nbefore, you should already be used to this, just remember you can't import npm packages like \r\nyou can in node -- currently, hug only imports from relative file paths.\r\n\r\n## A Simple Example\r\nSay I have two files:\r\n```javascript\r\n// required.js \r\nexports.message = \"Hello, world!\";\r\n```\r\n\r\n```javascript\r\n// requiree.js\r\nvar otherFile = require('required.js');\r\nalert(otherFile.message);\r\n```\r\n\r\n```javascript\r\n// grunt.js\r\nmodule.exports = function(grunt){\r\n grunt.initConfig({\r\n \thug: {\r\n \t\tsimple: {\r\n \t\t\tsrc: \"./example/simple/**/*\",\r\n \t\t\tdest: \"./tmp/simple-example.js\"\r\n \t\t}\r\n \t}\r\n });\r\n}\r\n```\r\n\r\nWhen we run `grunt hug`, simple-example.js is generated. When simple-example.js runs in a browser, \r\nit will alert \"Hello, world!\". Note that the window object is never touched, the entire application \r\nis within a closure, it leaves no trace after it's run. Here is the file itself:\r\n\r\n```javascript\r\n// simple-example.js\r\n(function(){\r\n\tvar __m0=(function(module,exports){module.exports=exports;\r\n\t\texports.message = \"Hello, world!\";\r\n\t\t;return module.exports;\r\n\t}({},{}));\r\n\r\n\tvar __m1=(function(module,exports){module.exports=exports;\r\n\t\tvar otherFile = __m0;\r\n\r\n\t\talert(otherFile.message);\r\n\t\t;return module.exports;\r\n\t}({},{}));\r\n}());\r\n```\r\n\r\n## A More Complex Example\r\n\r\nSay I have the following file structure:\r\n```javascript\r\nsrc/\r\n    language/\r\n        message/\r\n                aSaying.js\r\n        composer.js\r\n        words.js\r\n    exports.js\r\n    speak.js\r\ngrunt.js\r\n```\r\n\r\nWith the following file contents:\r\n\r\n```javascript\r\n// src/language/message/aSaying.js\r\nvar theWord = require('../words.js').aWord;\r\nvar composer = require('../composer.js');\r\n\r\nexports.whatTheySay = composer(theWord);\r\n```\r\n\r\n```javascript\r\n// src/language/composer.js\r\nexports = function(anything){\r\n\treturn \"Hello, \" + anything + \"!\";\r\n};\r\n```\r\n\r\n```javascript\r\n// src/language/words.js\r\nexports.aWord = \"world\";\r\n```\r\n\r\n```javascript\r\n// src/exports.js\r\nexports.speak = require('./speak.js');\r\nexports.message = require('./language/message/aSaying.js').whatTheySay;\r\n```\r\n\r\n```javascript\r\n// src/speak.js\r\nvar theMessage = require('./language/message/aSaying.js').whatTheySay;\r\nmodule.exports = function(){\r\n\talert(theMessage);\r\n};\r\n```\r\n\r\n```javascript\r\n// grunt.js\r\n// ...other config stuff...\r\n// in the object passed into initConfig:\r\nhug: {\r\n\tadvanced: {\r\n      \t\tsrc: \"./src/**/*\",\r\n        \tdest: \"./tmp/advanced-example.js\",\r\n        \texportedVariable: \"myApi\",\r\n        \texports: \"./src/exports.js\"\r\n\t},\r\n}\r\n// ...other config stuff...\r\n```\r\n\r\nWhen grunt is asked to hugs these files, it'll concatinate the files in order of dependencies, \r\nwrap each file in an anonymous function, and match up dependencies.\r\n\r\nRunning `advanced-example.js` will create an object named `myApi` in the `window` object with the two variables\r\ndefined in exports.js as it's members. Running `myApi.speak()` will alert \"Hello, world\" in a browser.\r\n\r\n## Usage\r\n\r\n**If you've never used grunt before, you will find it very useful to review the \r\n[Getting Started](https://github.com/gruntjs/grunt/blob/0.3-stable/docs/getting_started.md) documentation.**\r\n\r\nInside your `grunt.js` file, in the object you pass to initConfig, add an object named `hug`. \r\nInside this object, add one or more objects for different `hug` tasks.\r\n\r\n#### Parameters\r\n\r\n##### src `String or Array`\r\n\r\nOne or more comma separated wildcard patterns as well as an array of wildcard patterns. These files define the source\r\ncode of your package. Which will be concatinated together.\r\n\r\n##### dest `String`\r\n\r\nThe path for the generated file. Grunt will automatically generate directories if they don't exit.\r\n\r\n##### (optional) exports `String`\r\n\r\nA path to a file to use as the exports object for the package. Whatever the file exports, will be exported by the entire\r\npackage. In essence, this file should define the external api of your package.\r\n\r\n##### (optional) exportedVariable `String` (defaults to \"exports\")\r\n\r\nIf exports is defined, this will be the variable exported to the environment. Whatever the `exports` file exports \r\nwill be assigned to this variable. By setting the value of this to \"module.exports\" you can create a package that\r\ncan be imported by other hug or nodejs applications.\r\n\r\n##### (optional & advanced) moduleVariableName `String` (defaults to \"module\")\r\n\r\nSetting this parameter will break compatibility with importable nodejs modules.\r\nThis parameter allows you to overwrite the variable name used to refer to modules internally. This is useful if\r\nyou already use the `module` variable for something else.\r\n\r\n##### (optional & advanced) exportsVariableName `String` (defaults to \"exports\")\r\n\r\nSetting this parameter will break compatibility with importable nodejs modules.\r\nThis parameter allows you to overwrite the variable name used to refer to exports internally. This is useful if\r\nyou already use the `exports` variable for something else.\r\n\r\n##### (optional & advanced) requireFunctionName `String` (defaults to \"require\")\r\n\r\nSetting this parameter will break compatibility with importable nodejs modules.\r\nThis parameter allows you to overwrite the variable name used to refer to the require function. \r\nThis is useful if you already use the `require` variable for something else.\r\n\r\n## Importing libraries\r\nWeb frameworks and applications that can normally be imported into nodejs applications work as intended.\r\nFor example, you can just `require` the underscore library file and use it as you would normally.\r\n\r\nLibraries which aren't node-friendly can be made importable without modifying the original file by adding an\r\n'adapter' file. Here's an example on how to make jQuery importable:\r\n\r\n```javascript\r\n// jquery-module.js\r\nrequire('./jquery.js');\r\nmodule.exports = window.jQuery;\r\njQuery.noConflict();\r\n```\r\n\r\nFirst we require the actual library so that it gets included in our package and so that it's evaluated before\r\nthis file. Then we export out the reference to jQuery. Finally, we call jQuery.noConflict() which returns the\r\njQuery window variable to it's previous owner (but our exports still points to the one we want).\r\n\r\nNow we can import jquery in other files like so: `var $ = require('./jquery-module.js');`.\r\n\r\n","_id":"grunt-hug@0.3.1","dist":{"shasum":"411719f1ac4b8c2bac6d673b1b0ae009e3267759","tarball":"https://registry.npmjs.org/grunt-hug/-/grunt-hug-0.3.1.tgz","integrity":"sha512-r4LI5WtZ9TyTt14rem8WNN+3BdSzbZZv0Q/X3C/EcJjL7AC+QPCqsqBsMCAqbzbzix8GRRC+wkuh5PyhvtmPVQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBaq0i98okoF4CUS88bAzrx8IuYPAfN+IQU6iKRPGnqBAiEAnd1HSFaLmsPHEcqdS4MK7dyyxY32tMC7TQJsZHUCsD8="}]},"_npmVersion":"1.1.59","_npmUser":{"name":"ozanturgut","email":"ozanturgut@gmail.com"},"maintainers":[{"name":"ozanturgut","email":"ozanturgut@gmail.com"}],"directories":{}},"0.3.2":{"name":"grunt-hug","description":"Concatinate your web application without worrying about the order of your files.","version":"0.3.2","homepage":"https://github.com/ozanturgut/grunt-hug","author":{"name":"Ozan Turgut","url":"http://oztu.org/"},"repository":{"type":"git","url":"git://github.com/ozanturgut/grunt-hug.git"},"bugs":{"url":"https://github.com/ozanturgut/grunt-hug/issues"},"licenses":[{"type":"Apache License 2.0","url":"https://github.com/ozanturgut/grunt-hug/blob/master/LICENSE-APACHE2"}],"main":"grunt.js","engines":{"node":">= 0.8.0"},"scripts":{"test":"grunt test"},"dependencies":{},"devDependencies":{"grunt":"~0.3.15","grunt-contrib-clean":"~0.3.1","mocks":"~0.0.10","sinon":"~1.5.2"},"keywords":["gruntplugin"],"readme":"# grunt-hug [![Build Status](https://secure.travis-ci.org/ozanturgut/grunt-hug.png?branch=master)](http://travis-ci.org/ozanturgut/grunt-hug)\r\n\r\nHug makes maintaining and packaging web applications easier, it is a [grunt](http://gruntjs.com) plugin. \r\nTell it how to find your files and it will concatinate them in the right order of dependencies. \r\nIt will also prevent accidental variable leakage between files by wrapping each file in a self-executing \r\nanonymous function.\r\n\r\n## Why Hugging Will Make You Happy\r\n\r\n* **Automated dependency resolution.** It will figure out the required order for your files when concatinating.\r\n* **File-level variables** declarations won't leak to the environment and will remain at file-level.\r\n* Allows you to **define an API** for the package which can be used by other applications.\r\n\r\n## Target Audience\r\n\r\nHugging occurs at build-time, so an application which needs to load it's dependencies at runtime (lazy loading) \r\nwon't benefit much from hugging -- you'll likely prefer [RequireJS](http://requirejs.org/). \r\n\r\nFor frameworks or compiled applications, hugging is awesome. Your code will be clean, safe, and boiler-plate-free. \r\nAs an added benefit, your unhugged code will work in nodejs applications so long as you're not using any \r\nbrowser-specific functions (for example, `alert`).\r\n\r\n## How to Hug\r\n\r\n* Define the variables that a file will expose by assigning them to the `exports` variable. An example:\r\n`exports.numbers = [1,2,3];`.\r\n* Retrieve the exports of another file by using the `require` function. An example:  \r\n`var fileExports = require(\"[A RELATIVE PATH]\")`. \r\n\r\nIf you want to assign something as the exports object itself, assign it to `module.exports`. Assigning anything\r\ndirectly to `exports` would replace the object pointer entirely. If you've done nodejs programming \r\nbefore, you should already be used to this, just remember you can't import npm packages like \r\nyou can in node -- currently, hug only imports from relative file paths.\r\n\r\n## A Simple Example\r\nSay I have two files:\r\n```javascript\r\n// required.js \r\nexports.message = \"Hello, world!\";\r\n```\r\n\r\n```javascript\r\n// requiree.js\r\nvar otherFile = require('required.js');\r\nalert(otherFile.message);\r\n```\r\n\r\n```javascript\r\n// grunt.js\r\nmodule.exports = function(grunt){\r\n grunt.initConfig({\r\n \thug: {\r\n \t\tsimple: {\r\n \t\t\tsrc: \"./example/simple/**/*\",\r\n \t\t\tdest: \"./tmp/simple-example.js\"\r\n \t\t}\r\n \t}\r\n });\r\n}\r\n```\r\n\r\nWhen we run `grunt hug`, simple-example.js is generated. When simple-example.js runs in a browser, \r\nit will alert \"Hello, world!\". Note that the window object is never touched, the entire application \r\nis within a closure, it leaves no trace after it's run. Here is the file itself:\r\n\r\n```javascript\r\n// simple-example.js\r\n(function(){\r\n\tvar __m0=(function(module,exports){module.exports=exports;\r\n\t\texports.message = \"Hello, world!\";\r\n\t\t;return module.exports;\r\n\t}({},{}));\r\n\r\n\tvar __m1=(function(module,exports){module.exports=exports;\r\n\t\tvar otherFile = __m0;\r\n\r\n\t\talert(otherFile.message);\r\n\t\t;return module.exports;\r\n\t}({},{}));\r\n}());\r\n```\r\n\r\n## A More Complex Example\r\n\r\nSay I have the following file structure:\r\n```javascript\r\nsrc/\r\n    language/\r\n        message/\r\n                aSaying.js\r\n        composer.js\r\n        words.js\r\n    exports.js\r\n    speak.js\r\ngrunt.js\r\n```\r\n\r\nWith the following file contents:\r\n\r\n```javascript\r\n// src/language/message/aSaying.js\r\nvar theWord = require('../words.js').aWord;\r\nvar composer = require('../composer.js');\r\n\r\nexports.whatTheySay = composer(theWord);\r\n```\r\n\r\n```javascript\r\n// src/language/composer.js\r\nexports = function(anything){\r\n\treturn \"Hello, \" + anything + \"!\";\r\n};\r\n```\r\n\r\n```javascript\r\n// src/language/words.js\r\nexports.aWord = \"world\";\r\n```\r\n\r\n```javascript\r\n// src/exports.js\r\nexports.speak = require('./speak.js');\r\nexports.message = require('./language/message/aSaying.js').whatTheySay;\r\n```\r\n\r\n```javascript\r\n// src/speak.js\r\nvar theMessage = require('./language/message/aSaying.js').whatTheySay;\r\nmodule.exports = function(){\r\n\talert(theMessage);\r\n};\r\n```\r\n\r\n```javascript\r\n// grunt.js\r\n// ...other config stuff...\r\n// in the object passed into initConfig:\r\nhug: {\r\n\tadvanced: {\r\n      \t\tsrc: \"./src/**/*\",\r\n        \tdest: \"./tmp/advanced-example.js\",\r\n        \texportedVariable: \"myApi\",\r\n        \texports: \"./src/exports.js\"\r\n\t},\r\n}\r\n// ...other config stuff...\r\n```\r\n\r\nWhen grunt is asked to hugs these files, it'll concatinate the files in order of dependencies, \r\nwrap each file in an anonymous function, and match up dependencies.\r\n\r\nRunning `advanced-example.js` will create an object named `myApi` in the `window` object with the two variables\r\ndefined in exports.js as it's members. Running `myApi.speak()` will alert \"Hello, world\" in a browser.\r\n\r\n## Usage\r\n\r\n**If you've never used grunt before, you will find it very useful to review the \r\n[Getting Started](https://github.com/gruntjs/grunt/blob/0.3-stable/docs/getting_started.md) documentation.**\r\n\r\nInside your `grunt.js` file, in the object you pass to initConfig, add an object named `hug`. \r\nInside this object, add one or more objects for different `hug` tasks.\r\n\r\n#### Parameters\r\n\r\n##### src `String or Array`\r\n\r\nOne or more comma separated wildcard patterns as well as an array of wildcard patterns. These files define the source\r\ncode of your package. Which will be concatinated together.\r\n\r\n##### dest `String`\r\n\r\nThe path for the generated file. Grunt will automatically generate directories if they don't exit.\r\n\r\n##### (optional) exports `String`\r\n\r\nA path to a file to use as the exports object for the package. Whatever the file exports, will be exported by the entire\r\npackage. In essence, this file should define the external api of your package.\r\n\r\n##### (optional) exportedVariable `String` (defaults to \"exports\")\r\n\r\nIf exports is defined, this will be the variable exported to the environment. Whatever the `exports` file exports \r\nwill be assigned to this variable. By setting the value of this to \"module.exports\" you can create a package that\r\ncan be imported by other hug or nodejs applications.\r\n\r\n##### (optional & advanced) moduleVariableName `String` (defaults to \"module\")\r\n\r\nSetting this parameter will break compatibility with importable nodejs modules.\r\nThis parameter allows you to overwrite the variable name used to refer to modules internally. This is useful if\r\nyou already use the `module` variable for something else.\r\n\r\n##### (optional & advanced) exportsVariableName `String` (defaults to \"exports\")\r\n\r\nSetting this parameter will break compatibility with importable nodejs modules.\r\nThis parameter allows you to overwrite the variable name used to refer to exports internally. This is useful if\r\nyou already use the `exports` variable for something else.\r\n\r\n##### (optional & advanced) requireFunctionName `String` (defaults to \"require\")\r\n\r\nSetting this parameter will break compatibility with importable nodejs modules.\r\nThis parameter allows you to overwrite the variable name used to refer to the require function. \r\nThis is useful if you already use the `require` variable for something else.\r\n\r\n## Importing libraries\r\nWeb frameworks and applications that can normally be imported into nodejs applications work as intended.\r\nFor example, you can just `require` the underscore library file and use it as you would normally.\r\n\r\nLibraries which aren't node-friendly can be made importable without modifying the original file by adding an\r\n'adapter' file. Here's an example on how to make jQuery importable:\r\n\r\n```javascript\r\n// jquery-module.js\r\nrequire('./jquery.js');\r\nmodule.exports = window.jQuery;\r\njQuery.noConflict();\r\n```\r\n\r\nFirst we require the actual library so that it gets included in our package and so that it's evaluated before\r\nthis file. Then we export out the reference to jQuery. Finally, we call jQuery.noConflict() which returns the\r\njQuery window variable to it's previous owner (but our exports still points to the one we want).\r\n\r\nNow we can import jquery in other files like so: `var $ = require('./jquery-module.js');`.\r\n\r\n","_id":"grunt-hug@0.3.2","dist":{"shasum":"cd9f73a7dfd3f56d77428c8c06bf70edfa50b1fe","tarball":"https://registry.npmjs.org/grunt-hug/-/grunt-hug-0.3.2.tgz","integrity":"sha512-eaYPujeHWOQECJbZCUr7ABZTtvSjFQJnCOGPe3f065jq6Iyr9aw9CrD9WeD5v9ICwz312T0Nx2M9UZopT5atGQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH3ccyhO5VNfp1YJNv/l5q9Evu0Srwer75zxd6lTl1q0AiEAoMRJD+93seUzSugES6RG7fH1InRy5J6cMAa0WFGq+5A="}]},"_npmVersion":"1.1.59","_npmUser":{"name":"ozanturgut","email":"ozanturgut@gmail.com"},"maintainers":[{"name":"ozanturgut","email":"ozanturgut@gmail.com"}],"directories":{}},"0.4.0":{"name":"grunt-hug","description":"Concatinate your web application without worrying about the order of your files.","version":"0.4.0","homepage":"https://github.com/ozanturgut/grunt-hug","author":{"name":"Ozan Turgut","url":"http://oztu.org/"},"repository":{"type":"git","url":"git://github.com/ozanturgut/grunt-hug.git"},"bugs":{"url":"https://github.com/ozanturgut/grunt-hug/issues"},"licenses":[{"type":"Apache License 2.0","url":"https://github.com/ozanturgut/grunt-hug/blob/master/LICENSE-APACHE2"}],"main":"grunt.js","scripts":{"test":"grunt test"},"dependencies":{},"devDependencies":{"grunt":"~0.3.15","grunt-contrib-clean":"~0.3.1","mocks":"~0.0.10","sinon":"~1.5.2"},"keywords":["gruntplugin"],"readme":"# grunt-hug [![Build Status](https://secure.travis-ci.org/ozanturgut/grunt-hug.png?branch=master)](http://travis-ci.org/ozanturgut/grunt-hug)\n\nHug makes maintaining and packaging web applications easier, it is a [grunt](http://gruntjs.com) plugin. \nTell it how to find your files and it will concatinate them in the right order of dependencies. \nIt will also prevent accidental variable leakage between files by wrapping each file in a self-executing \nanonymous function.\n\n## Why Hugging Will Make You Happy\n\n* **Node-like `require` statements.** This tells grunt how your files are related so it can package your files in the\nright order. These statements won't be in the final packaged file.\n* **Automated dependency resolution.** It will figure out the required order for your files when concatinating.\n* **Path searching for dependencies.** Works great with[Bower](http://twitter.github.com/bower/) or \n[NPM](https://npmjs.org/), just add them to the search path.\n* **File-level variables** declarations won't leak to the environment and will remain at file-level.\n* Allows you to **define an API** for the package which can be used by other applications.\n\n## Target Audience\n\nHugging occurs at build-time, so an application which needs to load it's dependencies at runtime (lazy loading) \nwon't benefit much from hugging -- you'll likely prefer [RequireJS](http://requirejs.org/). \n\nFor frameworks or compiled applications, hugging is awesome. Your code will be clean, safe, and boiler-plate-free. \nAs an added benefit, your unhugged code will work in nodejs applications so long as you're not using any \nbrowser-specific functions (for example, `alert`).\n\n## How to Hug\n\n* Define the variables that a file will expose by assigning them to the `exports` variable. An example:\n`exports.numbers = [1,2,3];`.\n* Retrieve the exports of another file by using the `require` function. An example:  \n`var fileExports = require(\"[A RELATIVE PATH]\")`. \n\nIf you want to assign something as the exports object itself, assign it to `module.exports`. Assigning anything\ndirectly to `exports` would replace the object pointer entirely. If you've done nodejs programming \nbefore, you should already be used to this, just remember you can't import npm packages like \nyou can in node -- currently, hug only imports from relative file paths.\n\n## A Simple Example\nSay I have two files:\n```javascript\n// required.js \nexports.message = \"Hello, world!\";\n```\n\n```javascript\n// requiree.js\nvar otherFile = require('required.js');\nalert(otherFile.message);\n```\n\n```javascript\n// grunt.js\nmodule.exports = function(grunt){\n grunt.initConfig({\n \thug: {\n \t\tsimple: {\n \t\t\tsrc: \"./example/simple/**/*\",\n \t\t\tdest: \"./tmp/simple-example.js\"\n \t\t}\n \t}\n });\n}\n```\n\nWhen we run `grunt hug`, simple-example.js is generated. When simple-example.js runs in a browser, \nit will alert \"Hello, world!\". Note that the window object is never touched, the entire application \nis within a closure, it leaves no trace after it's run. Here is the file itself:\n\n```javascript\n// simple-example.js\n(function(){\n\tvar __m0=(function(module,exports){module.exports=exports;\n\t\texports.message = \"Hello, world!\";\n\t\t;return module.exports;\n\t}({},{}));\n\n\tvar __m1=(function(module,exports){module.exports=exports;\n\t\tvar otherFile = __m0;\n\n\t\talert(otherFile.message);\n\t\t;return module.exports;\n\t}({},{}));\n}());\n```\n\n## A More Complex Example\n\nSay I have the following file structure:\n```javascript\nsrc/\n    language/\n        message/\n                aSaying.js\n        composer.js\n        words.js\n    exports.js\n    speak.js\ngrunt.js\n```\n\nWith the following file contents:\n\n```javascript\n// src/language/message/aSaying.js\nvar theWord = require('../words.js').aWord;\nvar composer = require('../composer.js');\n\nexports.whatTheySay = composer(theWord);\n```\n\n```javascript\n// src/language/composer.js\nexports = function(anything){\n\treturn \"Hello, \" + anything + \"!\";\n};\n```\n\n```javascript\n// src/language/words.js\nexports.aWord = \"world\";\n```\n\n```javascript\n// src/exports.js\nexports.speak = require('./speak.js');\nexports.message = require('./language/message/aSaying.js').whatTheySay;\n```\n\n```javascript\n// src/speak.js\nvar theMessage = require('./language/message/aSaying.js').whatTheySay;\nmodule.exports = function(){\n\talert(theMessage);\n};\n```\n\n```javascript\n// grunt.js\n// ...other config stuff...\n// in the object passed into initConfig:\nhug: {\n\tadvanced: {\n      \t\tsrc: \"./src/**/*\",\n        \tdest: \"./tmp/advanced-example.js\",\n        \texportedVariable: \"myApi\",\n        \texports: \"./src/exports.js\"\n\t},\n}\n// ...other config stuff...\n```\n\nWhen grunt is asked to hugs these files, it'll concatinate the files in order of dependencies, \nwrap each file in an anonymous function, and match up dependencies.\n\nRunning `advanced-example.js` will create an object named `myApi` in the `window` object with the two variables\ndefined in exports.js as it's members. Running `myApi.speak()` will alert \"Hello, world\" in a browser.\n\n## Usage\n\n**If you've never used grunt before, you will find it very useful to review the \n[Getting Started](https://github.com/gruntjs/grunt/blob/0.3-stable/docs/getting_started.md) documentation.**\n\nInside your `grunt.js` file, in the object you pass to initConfig, add an object named `hug`. \nInside this object, add one or more objects for different `hug` tasks.\n\n#### Parameters\n\n##### src `String or Array`\n\nOne or more comma separated wildcard patterns as well as an array of wildcard patterns. These files define the source\ncode of your package. Which will be concatinated together.\n\n##### dest `String`\n\nThe path for the generated file. Grunt will automatically generate directories if they don't exit.\n\n##### (optional) path `String or Array`\n\nGrunt will use the given paths as a base (in addition to the current directory) when resolving dependencies.\n\nFor example if you set `path` to `[\"./components\"]`, and grunt runs in to a file with `require('jquery/jquery.js')`\nGrunt will search for the file both in the location relative to where it was declared, and in \n`./components/jquery/jquery.js`. \nThis works nicely with package managers such as [Bower](http://twitter.github.com/bower/) or [NPM](https://npmjs.org/).\n\n##### (optional) extensions `String or Array`\n\nGrunt will use this list of extensions when trying to resolve dependencies for files it can't find. By default\nthe extensions array is ['', '.js'], meaning, grunt will first try to find an exact match and then try to find\nthe same filename with the '.js' extension. So in the previous example for `path` we could have just used\n`require('jquery/jquery')` and it would have worked just as well.\n\n##### (optional) header `String or Array`\n\nFile(s) which will be prepended to the beginning of the package, making any variable defined in them package-global.\nNote that these files do not use the exports/require pattern -- what they would normally define as global become\nlimited to the scope of the package, so any file can use their variables without requiring them in.\n\nThis is particularly useful for utility functions that you do not want to keep requiring, or for libraries which\nrequire other libraries in order to work.\n\n##### (optional) exports `String`\n\nA path to a file to use as the exports object for the package. Whatever the file exports, will be exported by the entire\npackage. In essence, this file should define the external api of your package.\n\n##### (optional) exportedVariable `String` (defaults to \"exports\")\n\nIf exports is defined, this will be the variable exported to the environment. Whatever the `exports` file exports \nwill be assigned to this variable. By setting the value of this to \"module.exports\" you can create a package that\ncan be imported by other hug or nodejs applications.\n\n##### (optional & advanced) moduleVariableName `String` (defaults to \"module\")\n\nSetting this parameter will break compatibility with importable nodejs modules.\nThis parameter allows you to overwrite the variable name used to refer to modules internally. This is useful if\nyou already use the `module` variable for something else.\n\n##### (optional & advanced) exportsVariableName `String` (defaults to \"exports\")\n\nSetting this parameter will break compatibility with importable nodejs modules.\nThis parameter allows you to overwrite the variable name used to refer to exports internally. This is useful if\nyou already use the `exports` variable for something else.\n\n##### (optional & advanced) requireFunctionName `String` (defaults to \"require\")\n\nSetting this parameter will break compatibility with importable nodejs modules.\nThis parameter allows you to overwrite the variable name used to refer to the require function. \nThis is useful if you already use the `require` variable for something else.\n\n## Importing libraries\nWeb frameworks and applications that can normally be imported into nodejs applications work as intended.\nFor example, you can just `require` the underscore library file and use it as you would normally.\n\nLibraries which aren't node-friendly can be made importable without modifying the original file by adding an\n'adapter' file. Here's an example on how to make jQuery importable:\n\n```javascript\n// jquery-module.js\nrequire('./jquery.js');\nmodule.exports = window.jQuery;\njQuery.noConflict();\n```\n\nFirst we require the actual library so that it gets included in our package and so that it's evaluated before\nthis file. Then we export out the reference to jQuery. Finally, we call jQuery.noConflict() which returns the\njQuery window variable to it's previous owner (but our exports still points to the one we want).\n\nNow we can import jquery in other files like so: `var $ = require('./jquery-module.js');`.\n\n### Soy Templates\nClosure (Soy) templates work beautifully with grunt-hug. Just set your file's namespace to \"module.exports\" and you're done! \nYou can now`require` the generated soy file and it will provide an object with the templates in it.\n","_id":"grunt-hug@0.4.0","dist":{"shasum":"e0d3335948538e84d7a9791c485436b21402e620","tarball":"https://registry.npmjs.org/grunt-hug/-/grunt-hug-0.4.0.tgz","integrity":"sha512-jhd5M4xhCAN4k5xiCyriXub5/I01eyi7tNitGDXVNyucIxkz1oeG+Ws7IscfFefZ4lc9dSJXKP9C5kQ6l5W9kw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDakd8sviDckSTJLJS5yzO0hMNTJjdNRATQOsEGPgMa6QIgEs7agDr/88IL6MbQ2MjgMyGST/3DfPXRU7wH6wiH7Is="}]},"_npmVersion":"1.1.59","_npmUser":{"name":"ozanturgut","email":"ozanturgut@gmail.com"},"maintainers":[{"name":"ozanturgut","email":"ozanturgut@gmail.com"}],"directories":{}},"0.4.1":{"name":"grunt-hug","description":"Concatinate your web application without worrying about the order of your files.","version":"0.4.1","homepage":"https://github.com/ozanturgut/grunt-hug","author":{"name":"Ozan Turgut","url":"http://oztu.org/"},"repository":{"type":"git","url":"git://github.com/ozanturgut/grunt-hug.git"},"bugs":{"url":"https://github.com/ozanturgut/grunt-hug/issues"},"licenses":[{"type":"Apache License 2.0","url":"https://github.com/ozanturgut/grunt-hug/blob/master/LICENSE-APACHE2"}],"main":"grunt.js","scripts":{"test":"grunt test"},"dependencies":{},"devDependencies":{"grunt":"~0.3.15","grunt-contrib-clean":"~0.3.1","mocks":"~0.0.10","sinon":"~1.5.2"},"keywords":["gruntplugin"],"readme":"# grunt-hug [![Build Status](https://secure.travis-ci.org/ozanturgut/grunt-hug.png?branch=master)](http://travis-ci.org/ozanturgut/grunt-hug)\r\n\r\nHug makes maintaining and packaging web applications easier, it is a [grunt](http://gruntjs.com) plugin. \r\nTell it how to find your files and it will concatinate them in the right order of dependencies. \r\nIt will also prevent accidental variable leakage between files by wrapping each file in a self-executing \r\nanonymous function.\r\n\r\n## Why Hugging Will Make You Happy\r\n\r\n* **Node-like `require` statements.** This tells grunt how your files are related so it can package your files in the\r\nright order. These statements won't be in the final packaged file.\r\n* **Automated dependency resolution.** It will figure out the required order for your files when concatinating.\r\n* **Path searching for dependencies.** Works great with[Bower](http://twitter.github.com/bower/) or \r\n[NPM](https://npmjs.org/), just add them to the search path.\r\n* **File-level variables** declarations won't leak to the environment and will remain at file-level.\r\n* Allows you to **define an API** for the package which can be used by other applications.\r\n\r\n## Target Audience\r\n\r\nHugging occurs at build-time, so an application which needs to load it's dependencies at runtime (lazy loading) \r\nwon't benefit much from hugging -- you'll likely prefer [RequireJS](http://requirejs.org/). \r\n\r\nFor frameworks or compiled applications, hugging is awesome. Your code will be clean, safe, and boiler-plate-free. \r\nAs an added benefit, your unhugged code will work in nodejs applications so long as you're not using any \r\nbrowser-specific functions (for example, `alert`).\r\n\r\n## How to Hug\r\n\r\n* Define the variables that a file will expose by assigning them to the `exports` variable. An example:\r\n`exports.numbers = [1,2,3];`.\r\n* Retrieve the exports of another file by using the `require` function. An example:  \r\n`var fileExports = require(\"[A RELATIVE PATH]\")`. \r\n\r\nIf you want to assign something as the exports object itself, assign it to `module.exports`. Assigning anything\r\ndirectly to `exports` would replace the object pointer entirely. If you've done nodejs programming \r\nbefore, you should already be used to this, just remember you can't import npm packages like \r\nyou can in node -- currently, hug only imports from relative file paths.\r\n\r\n## A Simple Example\r\nSay I have two files:\r\n```javascript\r\n// required.js \r\nexports.message = \"Hello, world!\";\r\n```\r\n\r\n```javascript\r\n// requiree.js\r\nvar otherFile = require('required.js');\r\nalert(otherFile.message);\r\n```\r\n\r\n```javascript\r\n// grunt.js\r\nmodule.exports = function(grunt){\r\n grunt.initConfig({\r\n \thug: {\r\n \t\tsimple: {\r\n \t\t\tsrc: \"./example/simple/**/*\",\r\n \t\t\tdest: \"./tmp/simple-example.js\"\r\n \t\t}\r\n \t}\r\n });\r\n}\r\n```\r\n\r\nWhen we run `grunt hug`, simple-example.js is generated. When simple-example.js runs in a browser, \r\nit will alert \"Hello, world!\". Note that the window object is never touched, the entire application \r\nis within a closure, it leaves no trace after it's run. Here is the file itself:\r\n\r\n```javascript\r\n// simple-example.js\r\n(function(){\r\n\tvar __m0=(function(module,exports){module.exports=exports;\r\n\t\texports.message = \"Hello, world!\";\r\n\t\t;return module.exports;\r\n\t}({},{}));\r\n\r\n\tvar __m1=(function(module,exports){module.exports=exports;\r\n\t\tvar otherFile = __m0;\r\n\r\n\t\talert(otherFile.message);\r\n\t\t;return module.exports;\r\n\t}({},{}));\r\n}());\r\n```\r\n\r\n## A More Complex Example\r\n\r\nSay I have the following file structure:\r\n```javascript\r\nsrc/\r\n    language/\r\n        message/\r\n                aSaying.js\r\n        composer.js\r\n        words.js\r\n    exports.js\r\n    speak.js\r\ngrunt.js\r\n```\r\n\r\nWith the following file contents:\r\n\r\n```javascript\r\n// src/language/message/aSaying.js\r\nvar theWord = require('../words.js').aWord;\r\nvar composer = require('../composer.js');\r\n\r\nexports.whatTheySay = composer(theWord);\r\n```\r\n\r\n```javascript\r\n// src/language/composer.js\r\nexports = function(anything){\r\n\treturn \"Hello, \" + anything + \"!\";\r\n};\r\n```\r\n\r\n```javascript\r\n// src/language/words.js\r\nexports.aWord = \"world\";\r\n```\r\n\r\n```javascript\r\n// src/exports.js\r\nexports.speak = require('./speak.js');\r\nexports.message = require('./language/message/aSaying.js').whatTheySay;\r\n```\r\n\r\n```javascript\r\n// src/speak.js\r\nvar theMessage = require('./language/message/aSaying.js').whatTheySay;\r\nmodule.exports = function(){\r\n\talert(theMessage);\r\n};\r\n```\r\n\r\n```javascript\r\n// grunt.js\r\n// ...other config stuff...\r\n// in the object passed into initConfig:\r\nhug: {\r\n\tadvanced: {\r\n      \t\tsrc: \"./src/**/*\",\r\n        \tdest: \"./tmp/advanced-example.js\",\r\n        \texportedVariable: \"myApi\",\r\n        \texports: \"./src/exports.js\"\r\n\t},\r\n}\r\n// ...other config stuff...\r\n```\r\n\r\nWhen grunt is asked to hugs these files, it'll concatinate the files in order of dependencies, \r\nwrap each file in an anonymous function, and match up dependencies.\r\n\r\nRunning `advanced-example.js` will create an object named `myApi` in the `window` object with the two variables\r\ndefined in exports.js as it's members. Running `myApi.speak()` will alert \"Hello, world\" in a browser.\r\n\r\n## Usage\r\n\r\n**If you've never used grunt before, you will find it very useful to review the \r\n[Getting Started](https://github.com/gruntjs/grunt/blob/0.3-stable/docs/getting_started.md) documentation.**\r\n\r\nInside your `grunt.js` file, in the object you pass to initConfig, add an object named `hug`. \r\nInside this object, add one or more objects for different `hug` tasks.\r\n\r\n#### Parameters\r\n\r\n##### src `String or Array`\r\n\r\nOne or more comma separated wildcard patterns as well as an array of wildcard patterns. These files define the source\r\ncode of your package. Which will be concatinated together.\r\n\r\n##### dest `String`\r\n\r\nThe path for the generated file. Grunt will automatically generate directories if they don't exit.\r\n\r\n##### (optional) path `String or Array`\r\n\r\nGrunt will use the given paths as a base (in addition to the current directory) when resolving dependencies.\r\n\r\nFor example if you set `path` to `[\"./components\"]`, and grunt runs in to a file with `require('jquery/jquery.js')`\r\nGrunt will search for the file both in the location relative to where it was declared, and in \r\n`./components/jquery/jquery.js`. \r\nThis works nicely with package managers such as [Bower](http://twitter.github.com/bower/) or [NPM](https://npmjs.org/).\r\n\r\n##### (optional) extensions `String or Array`\r\n\r\nGrunt will use this list of extensions when trying to resolve dependencies for files it can't find. By default\r\nthe extensions array is ['', '.js'], meaning, grunt will first try to find an exact match and then try to find\r\nthe same filename with the '.js' extension. So in the previous example for `path` we could have just used\r\n`require('jquery/jquery')` and it would have worked just as well.\r\n\r\n##### (optional) header `String or Array`\r\n\r\nFile(s) which will be prepended to the beginning of the package, making any variable defined in them package-global.\r\nNote that these files do not use the exports/require pattern -- what they would normally define as global become\r\nlimited to the scope of the package, so any file can use their variables without requiring them in.\r\n\r\nThis is particularly useful for utility functions that you do not want to keep requiring, or for libraries which\r\nrequire other libraries in order to work.\r\n\r\n##### (optional) exports `String`\r\n\r\nA path to a file to use as the exports object for the package. Whatever the file exports, will be exported by the entire\r\npackage. In essence, this file should define the external api of your package.\r\n\r\n##### (optional) exportedVariable `String` (defaults to \"exports\")\r\n\r\nIf exports is defined, this will be the variable exported to the environment. Whatever the `exports` file exports \r\nwill be assigned to this variable. By setting the value of this to \"module.exports\" you can create a package that\r\ncan be imported by other hug or nodejs applications.\r\n\r\n##### (optional & advanced) moduleVariableName `String` (defaults to \"module\")\r\n\r\nSetting this parameter will break compatibility with importable nodejs modules.\r\nThis parameter allows you to overwrite the variable name used to refer to modules internally. This is useful if\r\nyou already use the `module` variable for something else.\r\n\r\n##### (optional & advanced) exportsVariableName `String` (defaults to \"exports\")\r\n\r\nSetting this parameter will break compatibility with importable nodejs modules.\r\nThis parameter allows you to overwrite the variable name used to refer to exports internally. This is useful if\r\nyou already use the `exports` variable for something else.\r\n\r\n##### (optional & advanced) requireFunctionName `String` (defaults to \"require\")\r\n\r\nSetting this parameter will break compatibility with importable nodejs modules.\r\nThis parameter allows you to overwrite the variable name used to refer to the require function. \r\nThis is useful if you already use the `require` variable for something else.\r\n\r\n## Importing libraries\r\nWeb frameworks and applications that can normally be imported into nodejs applications work as intended.\r\nFor example, you can just `require` the underscore library file and use it as you would normally.\r\n\r\nLibraries which aren't node-friendly can be made importable without modifying the original file by adding an\r\n'adapter' file. Here's an example on how to make jQuery importable:\r\n\r\n```javascript\r\n// jquery-module.js\r\nrequire('./jquery.js');\r\nmodule.exports = window.jQuery;\r\njQuery.noConflict();\r\n```\r\n\r\nFirst we require the actual library so that it gets included in our package and so that it's evaluated before\r\nthis file. Then we export out the reference to jQuery. Finally, we call jQuery.noConflict() which returns the\r\njQuery window variable to it's previous owner (but our exports still points to the one we want).\r\n\r\nNow we can import jquery in other files like so: `var $ = require('./jquery-module.js');`.\r\n\r\n### Soy Templates\r\nClosure (Soy) templates work beautifully with grunt-hug. Just set your file's namespace to \"module.exports\" and you're done! \r\nYou can now`require` the generated soy file and it will provide an object with the templates in it.\r\n","readmeFilename":"README.md","_id":"grunt-hug@0.4.1","dist":{"shasum":"00b54e2f2aca614d040e48d98aa1641c11f76641","tarball":"https://registry.npmjs.org/grunt-hug/-/grunt-hug-0.4.1.tgz","integrity":"sha512-OnJCv488nrGNGfKL5opC9pt+p6Iqez54nvR/EyHUCz0b6dYvxAwg/LJJIUkwpDdz0qAsQgUfLoYa9I/IZTLI8w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDOzoky2A8apEPdj+2MmdUcXcgjmu3Q/t/mHbUGvPkBIQIhAKfAm2yuq3Q4bdCMmKHO/K++Wl7uuWAZ7CDtGEQhYqC+"}]},"_from":".","_npmVersion":"1.2.2","_npmUser":{"name":"ozanturgut","email":"ozanturgut@gmail.com"},"maintainers":[{"name":"ozanturgut","email":"ozanturgut@gmail.com"}],"directories":{}},"0.4.2":{"name":"grunt-hug","description":"Concatinate your web application without worrying about the order of your files.","version":"0.4.2","homepage":"https://github.com/ozanturgut/grunt-hug","author":{"name":"Ozan Turgut","url":"http://oztu.org/"},"repository":{"type":"git","url":"git://github.com/ozanturgut/grunt-hug.git"},"bugs":{"url":"https://github.com/ozanturgut/grunt-hug/issues"},"licenses":[{"type":"Apache License 2.0","url":"https://github.com/ozanturgut/grunt-hug/blob/master/LICENSE-APACHE2"}],"main":"grunt.js","scripts":{"test":"grunt test"},"dependencies":{},"devDependencies":{"grunt":"~0.3.15","grunt-contrib-clean":"~0.3.1","mocks":"~0.0.10","sinon":"~1.5.2"},"keywords":["gruntplugin"],"readme":"# grunt-hug [![Build Status](https://secure.travis-ci.org/ozanturgut/grunt-hug.png?branch=master)](http://travis-ci.org/ozanturgut/grunt-hug)\n\nHug makes maintaining and packaging web applications easier, it is a [grunt](http://gruntjs.com) plugin. \nTell it how to find your files and it will concatinate them in the right order of dependencies. \nIt will also prevent accidental variable leakage between files by wrapping each file in a self-executing \nanonymous function.\n\n## Why Hugging Will Make You Happy\n\n* **Node-like `require` statements.** This tells grunt how your files are related so it can package your files in the\nright order. These statements won't be in the final packaged file.\n* **Automated dependency resolution.** It will figure out the required order for your files when concatinating.\n* **Path searching for dependencies.** Works great with[Bower](http://twitter.github.com/bower/) or \n[NPM](https://npmjs.org/), just add them to the search path.\n* **File-level variables** declarations won't leak to the environment and will remain at file-level.\n* Allows you to **define an API** for the package which can be used by other applications.\n\n## Target Audience\n\nHugging occurs at build-time, so an application which needs to load it's dependencies at runtime (lazy loading) \nwon't benefit much from hugging -- you'll likely prefer [RequireJS](http://requirejs.org/). \n\nFor frameworks or compiled applications, hugging is awesome. Your code will be clean, safe, and boiler-plate-free. \nAs an added benefit, your unhugged code will work in nodejs applications so long as you're not using any \nbrowser-specific functions (for example, `alert`).\n\n## How to Hug\n\n* Define the variables that a file will expose by assigning them to the `exports` variable. An example:\n`exports.numbers = [1,2,3];`.\n* Retrieve the exports of another file by using the `require` function. An example:  \n`var fileExports = require(\"[A RELATIVE PATH]\")`. \n\nIf you want to assign something as the exports object itself, assign it to `module.exports`. Assigning anything\ndirectly to `exports` would replace the object pointer entirely. If you've done nodejs programming \nbefore, you should already be used to this, just remember you can't import npm packages like \nyou can in node -- currently, hug only imports from relative file paths.\n\n## A Simple Example\nSay I have two files:\n```javascript\n// required.js \nexports.message = \"Hello, world!\";\n```\n\n```javascript\n// requiree.js\nvar otherFile = require('required.js');\nalert(otherFile.message);\n```\n\n```javascript\n// grunt.js\nmodule.exports = function(grunt){\n grunt.initConfig({\n \thug: {\n \t\tsimple: {\n \t\t\tsrc: \"./example/simple/**/*\",\n \t\t\tdest: \"./tmp/simple-example.js\"\n \t\t}\n \t}\n });\n}\n```\n\nWhen we run `grunt hug`, simple-example.js is generated. When simple-example.js runs in a browser, \nit will alert \"Hello, world!\". Note that the window object is never touched, the entire application \nis within a closure, it leaves no trace after it's run. Here is the file itself:\n\n```javascript\n// simple-example.js\n(function(){\n\tvar __m0=(function(module,exports){module.exports=exports;\n\t\texports.message = \"Hello, world!\";\n\t\t;return module.exports;\n\t}({},{}));\n\n\tvar __m1=(function(module,exports){module.exports=exports;\n\t\tvar otherFile = __m0;\n\n\t\talert(otherFile.message);\n\t\t;return module.exports;\n\t}({},{}));\n}());\n```\n\n## A More Complex Example\n\nSay I have the following file structure:\n```javascript\nsrc/\n    language/\n        message/\n                aSaying.js\n        composer.js\n        words.js\n    exports.js\n    speak.js\ngrunt.js\n```\n\nWith the following file contents:\n\n```javascript\n// src/language/message/aSaying.js\nvar theWord = require('../words.js').aWord;\nvar composer = require('../composer.js');\n\nexports.whatTheySay = composer(theWord);\n```\n\n```javascript\n// src/language/composer.js\nexports = function(anything){\n\treturn \"Hello, \" + anything + \"!\";\n};\n```\n\n```javascript\n// src/language/words.js\nexports.aWord = \"world\";\n```\n\n```javascript\n// src/exports.js\nexports.speak = require('./speak.js');\nexports.message = require('./language/message/aSaying.js').whatTheySay;\n```\n\n```javascript\n// src/speak.js\nvar theMessage = require('./language/message/aSaying.js').whatTheySay;\nmodule.exports = function(){\n\talert(theMessage);\n};\n```\n\n```javascript\n// grunt.js\n// ...other config stuff...\n// in the object passed into initConfig:\nhug: {\n\tadvanced: {\n      \t\tsrc: \"./src/**/*\",\n        \tdest: \"./tmp/advanced-example.js\",\n        \texportedVariable: \"myApi\",\n        \texports: \"./src/exports.js\"\n\t},\n}\n// ...other config stuff...\n```\n\nWhen grunt is asked to hugs these files, it'll concatinate the files in order of dependencies, \nwrap each file in an anonymous function, and match up dependencies.\n\nRunning `advanced-example.js` will create an object named `myApi` in the `window` object with the two variables\ndefined in exports.js as it's members. Running `myApi.speak()` will alert \"Hello, world\" in a browser.\n\n## Usage\n\n**If you've never used grunt before, you will find it very useful to review the \n[Getting Started](https://github.com/gruntjs/grunt/blob/0.3-stable/docs/getting_started.md) documentation.**\n\nInside your `grunt.js` file, in the object you pass to initConfig, add an object named `hug`. \nInside this object, add one or more objects for different `hug` tasks.\n\n#### Parameters\n\n##### src `String or Array`\n\nOne or more comma separated wildcard patterns as well as an array of wildcard patterns. These files define the source\ncode of your package. Which will be concatinated together.\n\n##### dest `String`\n\nThe path for the generated file. Grunt will automatically generate directories if they don't exit.\n\n##### (optional) path `String or Array`\n\nGrunt will use the given paths as a base (in addition to the current directory) when resolving dependencies.\n\nFor example if you set `path` to `[\"./components\"]`, and grunt runs in to a file with `require('jquery/jquery.js')`\nGrunt will search for the file both in the location relative to where it was declared, and in \n`./components/jquery/jquery.js`. \nThis works nicely with package managers such as [Bower](http://twitter.github.com/bower/) or [NPM](https://npmjs.org/).\n\n##### (optional) extensions `String or Array`\n\nGrunt will use this list of extensions when trying to resolve dependencies for files it can't find. By default\nthe extensions array is ['', '.js'], meaning, grunt will first try to find an exact match and then try to find\nthe same filename with the '.js' extension. So in the previous example for `path` we could have just used\n`require('jquery/jquery')` and it would have worked just as well.\n\n##### (optional) header `String or Array`\n\nFile(s) which will be prepended to the beginning of the package, making any variable defined in them package-global.\nNote that these files do not use the exports/require pattern -- what they would normally define as global become\nlimited to the scope of the package, so any file can use their variables without requiring them in.\n\nThis is particularly useful for utility functions that you do not want to keep requiring, or for libraries which\nrequire other libraries in order to work.\n\n##### (optional) exports `String`\n\nA path to a file to use as the exports object for the package. Whatever the file exports, will be exported by the entire\npackage. In essence, this file should define the external api of your package.\n\n##### (optional) exportedVariable `String` (defaults to \"exports\")\n\nIf exports is defined, this will be the variable exported to the environment. Whatever the `exports` file exports \nwill be assigned to this variable. By setting the value of this to \"module.exports\" you can create a package that\ncan be imported by other hug or nodejs applications.\n\n##### (optional & advanced) moduleVariableName `String` (defaults to \"module\")\n\nSetting this parameter will break compatibility with importable nodejs modules.\nThis parameter allows you to overwrite the variable name used to refer to modules internally. This is useful if\nyou already use the `module` variable for something else.\n\n##### (optional & advanced) exportsVariableName `String` (defaults to \"exports\")\n\nSetting this parameter will break compatibility with importable nodejs modules.\nThis parameter allows you to overwrite the variable name used to refer to exports internally. This is useful if\nyou already use the `exports` variable for something else.\n\n##### (optional & advanced) requireFunctionName `String` (defaults to \"require\")\n\nSetting this parameter will break compatibility with importable nodejs modules.\nThis parameter allows you to overwrite the variable name used to refer to the require function. \nThis is useful if you already use the `require` variable for something else.\n\n## Importing libraries\nWeb frameworks and applications that can normally be imported into nodejs applications work as intended.\nFor example, you can just `require` the underscore library file and use it as you would normally.\n\nLibraries which aren't node-friendly can be made importable without modifying the original file by adding an\n'adapter' file. Here's an example on how to make jQuery importable:\n\n```javascript\n// jquery-module.js\nrequire('./jquery.js');\nmodule.exports = window.jQuery;\njQuery.noConflict();\n```\n\nFirst we require the actual library so that it gets included in our package and so that it's evaluated before\nthis file. Then we export out the reference to jQuery. Finally, we call jQuery.noConflict() which returns the\njQuery window variable to it's previous owner (but our exports still points to the one we want).\n\nNow we can import jquery in other files like so: `var $ = require('./jquery-module.js');`.\n\n### Soy Templates\nClosure (Soy) templates work beautifully with grunt-hug. Just set your file's namespace to \"module.exports\" and you're done! \nYou can now`require` the generated soy file and it will provide an object with the templates in it.\n","_id":"grunt-hug@0.4.2","dist":{"shasum":"97aca8511a9c084b288d57239c8b907da20a54fa","tarball":"https://registry.npmjs.org/grunt-hug/-/grunt-hug-0.4.2.tgz","integrity":"sha512-Ph3BkTJv0hxPR2jk/7SicsBIrZVfZmzEa2N+mVF7hyzISdXwwLUA/0F8IW9adR7UosX1KchBWFHhAQ1DBUNyfA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICSnuzXHdxui9ou4SKDsDOVJexcg0qJHmNF/p7tRKbkpAiEA7+ErralKt7oi1XnpQAT9CahnAhT9+vuHFjBUoDvtlKo="}]},"_npmVersion":"1.1.59","_npmUser":{"name":"ozanturgut","email":"ozanturgut@gmail.com"},"maintainers":[{"name":"ozanturgut","email":"ozanturgut@gmail.com"}],"directories":{}},"0.5.0":{"name":"grunt-hug","description":"Concatinate your web application without worrying about the order of your files.","version":"0.5.0","homepage":"https://github.com/ozanturgut/grunt-hug","author":{"name":"Ozan Turgut","url":"http://oztu.org/"},"repository":{"type":"git","url":"git://github.com/ozanturgut/grunt-hug.git"},"bugs":{"url":"https://github.com/ozanturgut/grunt-hug/issues"},"licenses":[{"type":"Apache License 2.0","url":"https://github.com/ozanturgut/grunt-hug/blob/master/LICENSE-APACHE2"}],"main":"grunt.js","scripts":{"test":"grunt test"},"dependencies":{},"devDependencies":{"grunt":"~0.4.1","grunt-contrib-clean":"~0.4.0rc6","grunt-contrib-nodeunit":"~0.1.1","grunt-contrib-jshint":"~0.1.0","mocks":"~0.0.10","sinon":"~1.5.2"},"keywords":["gruntplugin"],"readme":"# grunt-hug [![Build Status](https://secure.travis-ci.org/ozanturgut/grunt-hug.png?branch=master)](http://travis-ci.org/ozanturgut/grunt-hug)\r\n\r\nHug makes maintaining and packaging web applications easier, it is a [grunt](http://gruntjs.com) plugin. \r\nTell it how to find your files and it will concatinate them in the right order of dependencies. \r\nIt will also prevent accidental variable leakage between files by wrapping each file in a self-executing \r\nanonymous function.\r\n\r\n## Why Hugging Will Make You Happy\r\n\r\n* **Node-like `require` statements.** This tells grunt how your files are related so it can package your files in the\r\nright order. These statements won't be in the final packaged file.\r\n* **Automated dependency resolution.** It will figure out the required order for your files when concatinating.\r\n* **Path searching for dependencies.** Works great with[Bower](http://twitter.github.com/bower/) or \r\n[NPM](https://npmjs.org/), just add them to the search path.\r\n* **File-level variables** declarations won't leak to the environment and will remain at file-level.\r\n* Allows you to **define an API** for the package which can be used by other applications.\r\n\r\n## Target Audience\r\n\r\nHugging occurs at build-time, so an application which needs to load it's dependencies at runtime (lazy loading) \r\nwon't benefit much from hugging -- you'll likely prefer [RequireJS](http://requirejs.org/). \r\n\r\nFor frameworks or compiled applications, hugging is awesome. Your code will be clean, safe, and boiler-plate-free. \r\nAs an added benefit, your unhugged code will work in nodejs applications so long as you're not using any \r\nbrowser-specific functions (for example, `alert`).\r\n\r\n## How to Hug\r\n\r\n* Define the variables that a file will expose by assigning them to the `exports` variable. An example:\r\n`exports.numbers = [1,2,3];`.\r\n* Retrieve the exports of another file by using the `require` function. An example:  \r\n`var fileExports = require(\"[A RELATIVE PATH]\")`. \r\n\r\nIf you want to assign something as the exports object itself, assign it to `module.exports`. Assigning anything\r\ndirectly to `exports` would replace the object pointer entirely. If you've done nodejs programming \r\nbefore, you should already be used to this, just remember you can't import npm packages like \r\nyou can in node -- currently, hug only imports from relative file paths.\r\n\r\n## A Simple Example\r\nSay I have two files:\r\n```javascript\r\n// required.js \r\nexports.message = \"Hello, world!\";\r\n```\r\n\r\n```javascript\r\n// requiree.js\r\nvar otherFile = require('required.js');\r\nalert(otherFile.message);\r\n```\r\n\r\n```javascript\r\n// grunt.js\r\nmodule.exports = function(grunt){\r\n grunt.initConfig({\r\n \thug: {\r\n \t\tsimple: {\r\n \t\t\tsrc: \"./example/simple/**/*\",\r\n \t\t\tdest: \"./tmp/simple-example.js\"\r\n \t\t}\r\n \t}\r\n });\r\n}\r\n```\r\n\r\nWhen we run `grunt hug`, simple-example.js is generated. When simple-example.js runs in a browser, \r\nit will alert \"Hello, world!\". Note that the window object is never touched, the entire application \r\nis within a closure, it leaves no trace after it's run. Here is the file itself:\r\n\r\n```javascript\r\n// simple-example.js\r\n(function(){\r\n\tvar __m0=(function(module,exports){module.exports=exports;\r\n\t\texports.message = \"Hello, world!\";\r\n\t\t;return module.exports;\r\n\t}({},{}));\r\n\r\n\tvar __m1=(function(module,exports){module.exports=exports;\r\n\t\tvar otherFile = __m0;\r\n\r\n\t\talert(otherFile.message);\r\n\t\t;return module.exports;\r\n\t}({},{}));\r\n}());\r\n```\r\n\r\n## A More Complex Example\r\n\r\nSay I have the following file structure:\r\n```javascript\r\nsrc/\r\n    language/\r\n        message/\r\n                aSaying.js\r\n        composer.js\r\n        words.js\r\n    exports.js\r\n    speak.js\r\ngrunt.js\r\n```\r\n\r\nWith the following file contents:\r\n\r\n```javascript\r\n// src/language/message/aSaying.js\r\nvar theWord = require('../words.js').aWord;\r\nvar composer = require('../composer.js');\r\n\r\nexports.whatTheySay = composer(theWord);\r\n```\r\n\r\n```javascript\r\n// src/language/composer.js\r\nexports = function(anything){\r\n\treturn \"Hello, \" + anything + \"!\";\r\n};\r\n```\r\n\r\n```javascript\r\n// src/language/words.js\r\nexports.aWord = \"world\";\r\n```\r\n\r\n```javascript\r\n// src/exports.js\r\nexports.speak = require('./speak.js');\r\nexports.message = require('./language/message/aSaying.js').whatTheySay;\r\n```\r\n\r\n```javascript\r\n// src/speak.js\r\nvar theMessage = require('./language/message/aSaying.js').whatTheySay;\r\nmodule.exports = function(){\r\n\talert(theMessage);\r\n};\r\n```\r\n\r\n```javascript\r\n// grunt.js\r\n// ...other config stuff...\r\n// in the object passed into initConfig:\r\nhug: {\r\n\tadvanced: {\r\n      \t\tsrc: \"./src/**/*\",\r\n        \tdest: \"./tmp/advanced-example.js\",\r\n        \texportedVariable: \"myApi\",\r\n        \texports: \"./src/exports.js\"\r\n\t},\r\n}\r\n// ...other config stuff...\r\n```\r\n\r\nWhen grunt is asked to hugs these files, it'll concatinate the files in order of dependencies, \r\nwrap each file in an anonymous function, and match up dependencies.\r\n\r\nRunning `advanced-example.js` will create an object named `myApi` in the `window` object with the two variables\r\ndefined in exports.js as it's members. Running `myApi.speak()` will alert \"Hello, world\" in a browser.\r\n\r\n## Usage\r\n\r\n**If you've never used grunt before, you will find it very useful to review the \r\n[Getting Started](https://github.com/gruntjs/grunt/blob/0.3-stable/docs/getting_started.md) documentation.**\r\n\r\nInside your `grunt.js` file, in the object you pass to initConfig, add an object named `hug`. \r\nInside this object, add one or more objects for different `hug` tasks.\r\n\r\n#### Parameters\r\n\r\n##### src `String or Array`\r\n\r\nOne or more comma separated wildcard patterns as well as an array of wildcard patterns. These files define the source\r\ncode of your package. Which will be concatinated together.\r\n\r\n##### dest `String`\r\n\r\nThe path for the generated file. Grunt will automatically generate directories if they don't exit.\r\n\r\n##### (optional) path `String or Array`\r\n\r\nGrunt will use the given paths as a base (in addition to the current directory) when resolving dependencies.\r\n\r\nFor example if you set `path` to `[\"./components\"]`, and grunt runs in to a file with `require('jquery/jquery.js')`\r\nGrunt will search for the file both in the location relative to where it was declared, and in \r\n`./components/jquery/jquery.js`. \r\nThis works nicely with package managers such as [Bower](http://twitter.github.com/bower/) or [NPM](https://npmjs.org/).\r\n\r\n##### (optional) extensions `String or Array`\r\n\r\nGrunt will use this list of extensions when trying to resolve dependencies for files it can't find. By default\r\nthe extensions array is ['', '.js'], meaning, grunt will first try to find an exact match and then try to find\r\nthe same filename with the '.js' extension. So in the previous example for `path` we could have just used\r\n`require('jquery/jquery')` and it would have worked just as well.\r\n\r\n##### (optional) header `String or Array`\r\n\r\nFile(s) which will be prepended to the beginning of the package, making any variable defined in them package-global.\r\nNote that these files do not use the exports/require pattern -- what they would normally define as global become\r\nlimited to the scope of the package, so any file can use their variables without requiring them in.\r\n\r\nThis is particularly useful for utility functions that you do not want to keep requiring, or for libraries which\r\nrequire other libraries in order to work.\r\n\r\n##### (optional) exports `String`\r\n\r\nA path to a file to use as the exports object for the package. Whatever the file exports, will be exported by the entire\r\npackage. In essence, this file should define the external api of your package.\r\n\r\n##### (optional) exportedVariable `String` (defaults to \"exports\")\r\n\r\nIf exports is defined, this will be the variable exported to the environment. Whatever the `exports` file exports \r\nwill be assigned to this variable. By setting the value of this to \"module.exports\" you can create a package that\r\ncan be imported by other hug or nodejs applications.\r\n\r\n##### (optional & advanced) moduleVariableName `String` (defaults to \"module\")\r\n\r\nSetting this parameter will break compatibility with importable nodejs modules.\r\nThis parameter allows you to overwrite the variable name used to refer to modules internally. This is useful if\r\nyou already use the `module` variable for something else.\r\n\r\n##### (optional & advanced) exportsVariableName `String` (defaults to \"exports\")\r\n\r\nSetting this parameter will break compatibility with importable nodejs modules.\r\nThis parameter allows you to overwrite the variable name used to refer to exports internally. This is useful if\r\nyou already use the `exports` variable for something else.\r\n\r\n##### (optional & advanced) requireFunctionName `String` (defaults to \"require\")\r\n\r\nSetting this parameter will break compatibility with importable nodejs modules.\r\nThis parameter allows you to overwrite the variable name used to refer to the require function. \r\nThis is useful if you already use the `require` variable for something else.\r\n\r\n## Importing libraries\r\nWeb frameworks and applications that can normally be imported into nodejs applications work as intended.\r\nFor example, you can just `require` the underscore library file and use it as you would normally.\r\n\r\nLibraries which aren't node-friendly can be made importable without modifying the original file by adding an\r\n'adapter' file. Here's an example on how to make jQuery importable:\r\n\r\n```javascript\r\n// jquery-module.js\r\nrequire('./jquery.js');\r\nmodule.exports = window.jQuery;\r\njQuery.noConflict();\r\n```\r\n\r\nFirst we require the actual library so that it gets included in our package and so that it's evaluated before\r\nthis file. Then we export out the reference to jQuery. Finally, we call jQuery.noConflict() which returns the\r\njQuery window variable to it's previous owner (but our exports still points to the one we want).\r\n\r\nNow we can import jquery in other files like so: `var $ = require('./jquery-module.js');`.\r\n\r\n### Soy Templates\r\nClosure (Soy) templates work beautifully with grunt-hug. Just set your file's namespace to \"module.exports\" and you're done! \r\nYou can now`require` the generated soy file and it will provide an object with the templates in it.\r\n","readmeFilename":"README.md","_id":"grunt-hug@0.5.0","dist":{"shasum":"47e48d9122dd780526442d60d4d480989456dcd7","tarball":"https://registry.npmjs.org/grunt-hug/-/grunt-hug-0.5.0.tgz","integrity":"sha512-hyu30SnLCPcpeI4Drsym4fhc7JqneCIeESvpdM22boXFcpk6bwo/VUIiuiybXK9g9k1tdJLUSlAfKwkmcJol2g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDXdRj8pPR1hp60IGLjUY3NV4Zrn92GodYvwATCsdylvAiAdKYFQwMC34hFJy8OuEdx/El/L0EiNrkqPfLoCDaGKSA=="}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"ozanturgut","email":"ozanturgut@gmail.com"},"maintainers":[{"name":"ozanturgut","email":"ozanturgut@gmail.com"}]},"0.5.2":{"name":"grunt-hug","description":"Concatinate your web application without worrying about the order of your files.","version":"0.5.2","homepage":"https://github.com/ozanturgut/grunt-hug","author":{"name":"Ozan Turgut","url":"http://oztu.org/"},"repository":{"type":"git","url":"git://github.com/ozanturgut/grunt-hug.git"},"bugs":{"url":"https://github.com/ozanturgut/grunt-hug/issues"},"licenses":[{"type":"Apache License 2.0","url":"https://github.com/ozanturgut/grunt-hug/blob/master/LICENSE-APACHE2"}],"main":"grunt.js","scripts":{"test":"grunt test"},"dependencies":{},"devDependencies":{"grunt":"~0.4.1","grunt-contrib-clean":"~0.4.0rc6","grunt-contrib-nodeunit":"~0.1.1","grunt-contrib-jshint":"~0.1.0","mocks":"~0.0.10","sinon":"~1.5.2"},"keywords":["gruntplugin"],"readme":"# grunt-hug [![Build Status](https://secure.travis-ci.org/ozanturgut/grunt-hug.png?branch=master)](http://travis-ci.org/ozanturgut/grunt-hug)\n\nHug makes maintaining and packaging web applications easier, it is a [grunt](http://gruntjs.com) plugin. \nTell it how to find your files and it will concatinate them in the right order of dependencies. \nIt will also prevent accidental variable leakage between files by wrapping each file in a self-executing \nanonymous function.\n\n## Why Hugging Will Make You Happy\n\n* **Node-like `require` statements.** This tells grunt how your files are related so it can package your files in the\nright order. These statements won't be in the final packaged file.\n* **Automated dependency resolution.** It will figure out the required order for your files when concatinating.\n* **Path searching for dependencies.** Works great with[Bower](http://twitter.github.com/bower/) or \n[NPM](https://npmjs.org/), just add them to the search path.\n* **File-level variables** declarations won't leak to the environment and will remain at file-level.\n* Allows you to **define an API** for the package which can be used by other applications.\n\n## Target Audience\n\nHugging occurs at build-time, so an application which needs to load it's dependencies at runtime (lazy loading) \nwon't benefit much from hugging -- you'll likely prefer [RequireJS](http://requirejs.org/). \n\nFor frameworks or compiled applications, hugging is awesome. Your code will be clean, safe, and boiler-plate-free. \nAs an added benefit, your unhugged code will work in nodejs applications so long as you're not using any \nbrowser-specific functions (for example, `alert`).\n\n## How to Hug\n\n* Define the variables that a file will expose by assigning them to the `exports` variable. An example:\n`exports.numbers = [1,2,3];`.\n* Retrieve the exports of another file by using the `require` function. An example:  \n`var fileExports = require(\"[A RELATIVE PATH]\")`. \n\nIf you want to assign something as the exports object itself, assign it to `module.exports`. Assigning anything\ndirectly to `exports` would replace the object pointer entirely. If you've done nodejs programming \nbefore, you should already be used to this, just remember you can't import npm packages like \nyou can in node -- currently, hug only imports from relative file paths.\n\n## A Simple Example\nSay I have two files:\n```javascript\n// required.js \nexports.message = \"Hello, world!\";\n```\n\n```javascript\n// requiree.js\nvar otherFile = require('required.js');\nalert(otherFile.message);\n```\n\n```javascript\n// grunt.js\nmodule.exports = function(grunt){\n grunt.initConfig({\n \thug: {\n \t\tsimple: {\n \t\t\tsrc: \"./example/simple/**/*\",\n \t\t\tdest: \"./tmp/simple-example.js\"\n \t\t}\n \t}\n });\n}\n```\n\nWhen we run `grunt hug`, simple-example.js is generated. When simple-example.js runs in a browser, \nit will alert \"Hello, world!\". Note that the window object is never touched, the entire application \nis within a closure, it leaves no trace after it's run. Here is the file itself:\n\n```javascript\n// simple-example.js\n(function(){\n\tvar __m0=(function(module,exports){module.exports=exports;\n\t\texports.message = \"Hello, world!\";\n\t\t;return module.exports;\n\t}({},{}));\n\n\tvar __m1=(function(module,exports){module.exports=exports;\n\t\tvar otherFile = __m0;\n\n\t\talert(otherFile.message);\n\t\t;return module.exports;\n\t}({},{}));\n}());\n```\n\n## A More Complex Example\n\nSay I have the following file structure:\n```javascript\nsrc/\n    language/\n        message/\n                aSaying.js\n        composer.js\n        words.js\n    exports.js\n    speak.js\ngrunt.js\n```\n\nWith the following file contents:\n\n```javascript\n// src/language/message/aSaying.js\nvar theWord = require('../words.js').aWord;\nvar composer = require('../composer.js');\n\nexports.whatTheySay = composer(theWord);\n```\n\n```javascript\n// src/language/composer.js\nexports = function(anything){\n\treturn \"Hello, \" + anything + \"!\";\n};\n```\n\n```javascript\n// src/language/words.js\nexports.aWord = \"world\";\n```\n\n```javascript\n// src/exports.js\nexports.speak = require('./speak.js');\nexports.message = require('./language/message/aSaying.js').whatTheySay;\n```\n\n```javascript\n// src/speak.js\nvar theMessage = require('./language/message/aSaying.js').whatTheySay;\nmodule.exports = function(){\n\talert(theMessage);\n};\n```\n\n```javascript\n// grunt.js\n// ...other config stuff...\n// in the object passed into initConfig:\nhug: {\n\tadvanced: {\n      \t\tsrc: \"./src/**/*\",\n        \tdest: \"./tmp/advanced-example.js\",\n        \texportedVariable: \"myApi\",\n        \texports: \"./src/exports.js\"\n\t},\n}\n// ...other config stuff...\n```\n\nWhen grunt is asked to hugs these files, it'll concatinate the files in order of dependencies, \nwrap each file in an anonymous function, and match up dependencies.\n\nRunning `advanced-example.js` will create an object named `myApi` in the `window` object with the two variables\ndefined in exports.js as it's members. Running `myApi.speak()` will alert \"Hello, world\" in a browser.\n\n## Usage\n\n**If you've never used grunt before, you will find it very useful to review the \n[Getting Started](https://github.com/gruntjs/grunt/blob/0.3-stable/docs/getting_started.md) documentation.**\n\nInside your `grunt.js` file, in the object you pass to initConfig, add an object named `hug`. \nInside this object, add one or more objects for different `hug` tasks.\n\n#### Parameters\n\n##### src `String or Array`\n\nOne or more comma separated wildcard patterns as well as an array of wildcard patterns. These files define the source\ncode of your package. Which will be concatinated together.\n\n##### dest `String`\n\nThe path for the generated file. Grunt will automatically generate directories if they don't exit.\n\n##### (optional) path `String or Array`\n\nGrunt will use the given paths as a base (in addition to the current directory) when resolving dependencies.\n\nFor example if you set `path` to `[\"./components\"]`, and grunt runs in to a file with `require('jquery/jquery.js')`\nGrunt will search for the file both in the location relative to where it was declared, and in \n`./components/jquery/jquery.js`. \nThis works nicely with package managers such as [Bower](http://twitter.github.com/bower/) or [NPM](https://npmjs.org/).\n\n##### (optional) extensions `String or Array`\n\nGrunt will use this list of extensions when trying to resolve dependencies for files it can't find. By default\nthe extensions array is ['', '.js'], meaning, grunt will first try to find an exact match and then try to find\nthe same filename with the '.js' extension. So in the previous example for `path` we could have just used\n`require('jquery/jquery')` and it would have worked just as well.\n\n##### (optional) header `String or Array`\n\nFile(s) which will be prepended to the beginning of the package, making any variable defined in them package-global.\nNote that these files do not use the exports/require pattern -- what they would normally define as global become\nlimited to the scope of the package, so any file can use their variables without requiring them in.\n\nThis is particularly useful for utility functions that you do not want to keep requiring, or for libraries which\nrequire other libraries in order to work.\n\n##### (optional) exports `String`\n\nA path to a file to use as the exports object for the package. Whatever the file exports, will be exported by the entire\npackage. In essence, this file should define the external api of your package.\n\n##### (optional) exportedVariable `String` (defaults to \"exports\")\n\nIf exports is defined, this will be the variable exported to the environment. Whatever the `exports` file exports \nwill be assigned to this variable. By setting the value of this to \"module.exports\" you can create a package that\ncan be imported by other hug or nodejs applications.\n\n##### (optional & advanced) moduleVariableName `String` (defaults to \"module\")\n\nSetting this parameter will break compatibility with importable nodejs modules.\nThis parameter allows you to overwrite the variable name used to refer to modules internally. This is useful if\nyou already use the `module` variable for something else.\n\n##### (optional & advanced) exportsVariableName `String` (defaults to \"exports\")\n\nSetting this parameter will break compatibility with importable nodejs modules.\nThis parameter allows you to overwrite the variable name used to refer to exports internally. This is useful if\nyou already use the `exports` variable for something else.\n\n##### (optional & advanced) requireFunctionName `String` (defaults to \"require\")\n\nSetting this parameter will break compatibility with importable nodejs modules.\nThis parameter allows you to overwrite the variable name used to refer to the require function. \nThis is useful if you already use the `require` variable for something else.\n\n## Importing libraries\nWeb frameworks and applications that can normally be imported into nodejs applications work as intended.\nFor example, you can just `require` the underscore library file and use it as you would normally.\n\nLibraries which aren't node-friendly can be made importable without modifying the original file by adding an\n'adapter' file. Here's an example on how to make jQuery importable:\n\n```javascript\n// jquery-module.js\nrequire('./jquery.js');\nmodule.exports = window.jQuery;\njQuery.noConflict();\n```\n\nFirst we require the actual library so that it gets included in our package and so that it's evaluated before\nthis file. Then we export out the reference to jQuery. Finally, we call jQuery.noConflict() which returns the\njQuery window variable to it's previous owner (but our exports still points to the one we want).\n\nNow we can import jquery in other files like so: `var $ = require('./jquery-module.js');`.\n\n### Soy Templates\nClosure (Soy) templates work beautifully with grunt-hug. Just set your file's namespace to \"module.exports\" and you're done! \nYou can now`require` the generated soy file and it will provide an object with the templates in it.\n","_id":"grunt-hug@0.5.2","dist":{"shasum":"e4a0ccb88b64733a252051e7993c11a70a0f43c2","tarball":"https://registry.npmjs.org/grunt-hug/-/grunt-hug-0.5.2.tgz","integrity":"sha512-6grl002YFVLrObMiAaWZ/pfqz8lAMPmMcYsnAnygGygqsUkgEoeCaRLwHaetC0evaTojBG1lJYOlE3/AEJLL8w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIA0ASjggdwY+3RPKm1lEo+J+rT4uXraWsxPFY6agqW05AiEAyCvzXviP1irhweB+AGcCIMvP7hSqI7+Yo5KkCvcOc0g="}]},"_npmVersion":"1.1.59","_npmUser":{"name":"ozanturgut","email":"ozanturgut@gmail.com"},"maintainers":[{"name":"ozanturgut","email":"ozanturgut@gmail.com"}]}},"readme":"# grunt-hug [![Build Status](https://secure.travis-ci.org/ozanturgut/grunt-hug.png?branch=master)](http://travis-ci.org/ozanturgut/grunt-hug)\n\nHug makes developing web applications easier. You provide a directory, grunt generates one combined file, performing dependency resolution along the way. It's like concat, except you don't have to worry about the order of your files. It also keeps your namespaces clean by limiting the scope of variable declarations to file-level by wrapping each file in an anonymous self-executing function.\n\n## Why Hugging Will Make You Happy\n\n* You provide a root directory, grunt figures out how to concatinate your files to fulfill dependency constraints.\n* Your file-level variables declarations will actually be scoped at file-level (they won't leak to the environment).\n* It'll make your minified files smaller because it explicitly defines what the external api will be (and therefore anything not in the external api can be safely renamed to something shorted during minifaction).\n* You can `require([relativePath])` other files to bring them into the current scope.\n* You can optionally generate one variable encompasing your entire API.\n\n## Target Audience\n\nHugging occurs at build-time, so an application which needs to load it's dependencies at runtime (lazy loading) won't benefit much from hugging -- you'll likely prefer the likes of [RequireJS](http://requirejs.org/). \n\nFor frameworks or compiled applications, hugging is awesome. Your code will be clean, safe, and boiler-plate-free. As an added benefit, your unhugged code will work in nodejs applications so long as you're not using any browser-specific functions.\n\n## Importing libraries\nYou likely depend on external libraries. Here two approaches you can take to import import them into Hug:\n* Some libraries automatically bind to an exports variable if it exists (ex: jQuery, Underscore), these can be treated like any other file in your package by using ```require()``` to bring them in to scope.\n* Libraries which declare a var or introduce a global variable can be added to the ```header``` of the package. The header is prepended to the package and the entire package is wrapped in an anonymous function, so if all the library does is declare variables, those variables will become package-level variables.\n\n## Simple Example\nSay I have two files:\n``` javascript\n// file1.js \nexports.word1 = \"hello\";\nexports.word2 = \"world\";\n```\n``` javascript\n// file2.js\nvar file1Exports = require('./file1.js');\nconsole.log(file1Exports.word1 + \" \" + file1Exports.word2);\n```\nWhen these files run through hug, this will be the generated file:\n``` javascript\n(function(){\n\tvar __module0 = (function(){\n\t\tvar module = {};\n\t\tvar exports = module.exports = {};\n\t\t\n\t\texports.word1 = \"hello\";\n\t\texports.word2 = \"world\";\n\t\t\n\t\treturn module.exports || exports;\n\t}());\n\t\n\tvar __module1 = (function(){\n\t\tvar module = {};\n\t\tvar exports = module.exports = {};\n\t\n\t\tvar file1Exports = __module0;\n\t\tconsole.log(file1Exports.word1 + \" \" + file1Exports.word2);\n\t\t\n\t\treturn module.exports || exports;\n\t}());\n\t\n\treturn {\"file1\":__module0,\"file2\":__module1};\n}());\n```\n\n## Complex Example\n\nSay I have the following file structure:\n```\nsrc/\n    language/\n        message/\n                aSaying.js\n        words.js\n        speaker.js\n    init.js\ngrunt.js\n```\n\nWith the following file contents:\n\n``` javascript\n// src/init.js\nvar theMessage = require('language/message/aSaying.js').whatTheySay;\nconsole.log(theMessage);\n```\n\n``` javascript\n// src/language/message/aSaying.js\nvar theWord = require('../words.js').aWord;\nvar speaker = require('../speaker.js');\n\nexports.whatTheySay = speaker(theWord);\n```\n\n``` javascript\n// src/language/words.js\nexports.aWord = \"world\";\n````\n\n``` javascript\n// src/language/speaker.js\nexports = function(anything){\n\treturn \"Hello, \" + anything + \"!\";\n};\n```\n\n``` javascript\n// grunt.js\n// ...other config stuff...\n// in the object passed into initConfig:\nhug: {\n\tdist: {\n\t\tsrc: 'src',\n\t\tdest: 'build/hi.js'\n\t}\n}\n// ...other config stuff...\n```\n\nWhen grunt is asked to hug this source tree, it'll concatinate the files in order of dependencies, and wrap each file in an anonymous function, and match up dependencies.\n\nRunning `hi.js` will output \"Hello, world!\" on the console, with no trace of the program ever running (nothing leaked to the global scope).\n\n## Usage\n\nInside your `grunt.js` file, in the object you pass to initConfig, add a section named `hug`. Inside this section, add 1 or more subsections for different `hug` tasks.\n\n#### Parameters\n\n##### src ```string```\n\nThis defines the root directory of your source tree. Any JS file under this directory will become part of the generated file.\n\n##### dest ```string```\n\nThis defines what the path for the generated file should be. Grunt will automatically generate directories if they don't exit.\n\n##### (optional) header ```file list```\n\nA list of files to prepend to the package. These files are not wrapped in anonymous functions, so any variables that are declared will be visible to the entire package. This is a good choice for utility functions or libraries which don't support exporting their variables.\n\n##### (optional) exportsVariable ```string```\n\nThis is an optional parameter. If provided, the generated file will produce a global variable with the given name holding the export tree. For example, if we had set `exportsVariable: 'hugExample'` for the example above, and ran the generated script, we would end up with a global variable like this:\n\n``` javascript\nconsole.log(hugExample);\n// Output:\n//\thugExample: {\n//\t\tlanguage: {\n//\t\t\tmessage: {\n//\t\t\t\taSaying: {\n//\t\t\t\twhatTheySay: 'Hello, world!'\n//\t\t\t},\n//\t\t\twords: {\n//\t\t\t\taWord: \"world\"\n//\t\t\t},\n//\t\t\tspeaker: function(anything){return \"Hello, \" + anything + \"!\";}\n//\t\t},\n//\t\tinit: {}\n//\t}\n```\nNote that you can't use the exportsVariable in the source code, you have to use the `require` method to access the exports of other files.\n\n## Known Limitations and Possibilities\n* You cannot `require` a file outside of your source tree. For third-party libraries use grunt `concat` to concatinate them ahead of the hug generated file. You'll also likely want to minify the generated file.\n* You can set `exportsVariable` to `exports` and use the generated file in another source tree (which can then also be hugged) as a way to cleanly encapsulate your APIs.\n\n","maintainers":[{"name":"ozanturgut","email":"ozanturgut@gmail.com"}],"time":{"modified":"2022-06-18T15:11:41.591Z","created":"2012-12-21T19:28:16.929Z","0.2.3":"2012-12-21T19:28:17.710Z","0.3.0":"2013-01-07T02:14:32.557Z","0.3.1":"2013-01-07T08:11:05.780Z","0.3.2":"2013-01-07T08:13:54.346Z","0.4.0":"2013-01-18T05:54:54.670Z","0.4.1":"2013-01-19T08:56:01.686Z","0.5.0":"2013-04-13T17:01:58.307Z","0.4.2":"2013-03-12T02:21:43.895Z","0.5.2":"2013-10-08T18:44:22.151Z"},"author":{"name":"Ozan Turgut","url":"http://oztu.org/"},"repository":{"type":"git","url":"git://github.com/ozanturgut/grunt-hug.git"}}