├── .gitattributes
├── .gitignore
├── .jshintrc
├── LICENSE
├── README.md
├── package.json
└── tasks
└── lodash.js
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *.log
3 | node_modules/
4 |
--------------------------------------------------------------------------------
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "camelcase": true,
3 | "curly": true,
4 | "immed": true,
5 | "indent": 2,
6 | "latedef": true,
7 | "laxbreak": true,
8 | "newcap": true,
9 | "noarg": true,
10 | "node": true,
11 | "noempty": true,
12 | "sub": true,
13 | "undef": true,
14 | "globals": {
15 | "exports": true,
16 | "module": true,
17 | "require": true
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright jQuery Foundation and other contributors
2 |
3 | This software consists of voluntary contributions made by many
4 | individuals. For exact contribution history, see the revision history
5 | available at https://github.com/lodash/lodash
6 |
7 | The following license applies to all parts of this software except as
8 | documented below:
9 |
10 | ====
11 |
12 | Permission is hereby granted, free of charge, to any person obtaining
13 | a copy of this software and associated documentation files (the
14 | "Software"), to deal in the Software without restriction, including
15 | without limitation the rights to use, copy, modify, merge, publish,
16 | distribute, sublicense, and/or sell copies of the Software, and to
17 | permit persons to whom the Software is furnished to do so, subject to
18 | the following conditions:
19 |
20 | The above copyright notice and this permission notice shall be
21 | included in all copies or substantial portions of the Software.
22 |
23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 |
31 | ====
32 |
33 | Copyright and related rights for sample code are waived via CC0. Sample
34 | code is defined as all source code displayed within the prose of the
35 | documentation.
36 |
37 | CC0: http://creativecommons.org/publicdomain/zero/1.0/
38 |
39 | ====
40 |
41 | Files located in the node_modules and vendor directories are externally
42 | maintained libraries used by this software which have their own
43 | licenses; we recommend you read them, as their terms may differ from the
44 | terms above.
45 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # grunt-lodash v0.5.1
2 |
3 | A Grunt wrapper around the [lodash](https://lodash.com/) command-line interface, [lodash-cli](https://npmjs.org/package/lodash-cli).
4 |
5 | ## Discontinued
6 |
7 | This plugin has been discontinued. No further development is expected.
8 |
9 | ## Getting Started
10 |
11 | This plugin requires Grunt `^0.4.1`.
12 | If you haven’t used [Grunt](http://gruntjs.com/) before, be sure to check out the [“Getting Started”](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you’re familiar with that process, you may install this plugin with this command:
13 |
14 | ```bash
15 | $ npm i --save-dev grunt-lodash
16 | ```
17 |
18 | Once grunt-lodash has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
19 |
20 | ```js
21 | grunt.loadNpmTasks('grunt-lodash');
22 | ```
23 |
24 | ### Overview
25 |
26 | In your project’s Gruntfile, add `lodash` to the data object passed to `grunt.initConfig`:
27 |
28 | ```js
29 | grunt.initConfig({
30 | 'lodash': {
31 | 'build': {
32 | // output location
33 | 'dest': 'build/lodash.build.js',
34 | 'options': {
35 | // modifiers for prepared builds
36 | // modern, strict, compat
37 | 'modifier': 'modern'
38 | }
39 | }
40 | }
41 | });
42 | ```
43 |
44 | This will produce the same output as:
45 |
46 | ```bash
47 | $ lodash modern -o build/lodash.build.js
48 | ```
49 |
50 | Finally, include `lodash` in your desired build task:
51 |
52 | ```js
53 | grunt.registerTask('build', [
54 | 'clean:dist',
55 | 'lodash'
56 | ]);
57 | ```
58 |
59 | ## Configuration
60 |
61 | For more details see the [lodash-cli documentation](https://lodash.com/custom-builds).
62 |
63 | ```js
64 | 'lodash': {
65 | 'target': {
66 | // output location
67 | 'dest': 'build/lodash.build.js'
68 | },
69 | 'options': {
70 | // modifiers for prepared builds
71 | // modern, strict, compat
72 | // also accepts an array to allow combination with 'strict'
73 | 'modifier': 'modern',
74 | 'modularize': true,
75 | 'category': ['collection', 'function'],
76 | 'exports': ['amd', 'commonjs', 'node'],
77 | 'iife': '!function(window,undefined){%output%}(this)',
78 | 'include': ['each', 'filter', 'map'],
79 | 'minus': ['result', 'shuffle'],
80 | 'plus': ['random', 'template'],
81 | 'template': './*.jst',
82 | 'settings': '{interpolate:/\\{\\{([\\s\\S]+?)\\}\\}/g}',
83 | 'moduleId': 'underscore',
84 | // with or without the `--`
85 | // these are the only tested options,
86 | // as the others don’t make sense to use here
87 | 'flags': [
88 | '--stdout',
89 | 'development',
90 | '--production',
91 | 'source-map'
92 | ],
93 | // with or without the `-`
94 | // these are the only tested options,
95 | // as the others don’t make sense to use here
96 | 'shortFlags': [
97 | 'c',
98 | '-d',
99 | 'p',
100 | '-m'
101 | ]
102 | }
103 | }
104 | ```
105 |
106 | ## Support
107 |
108 | Tested in Node.js 0.10, 0.12, 4, & 5.
109 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "grunt-lodash",
3 | "version": "0.5.1",
4 | "description": "A Grunt wrapper around lodash-cli.",
5 | "homepage": "https://github.com/lodash/grunt-lodash",
6 | "license": "MIT",
7 | "author": "Blaine Bublitz (https://github.com/phated)",
8 | "contributors": [
9 | "Blaine Bublitz (https://github.com/phated)",
10 | "John-David Dalton (http://allyoucanleet.com/)",
11 | "Mathias Bynens (https://mathiasbynens.be/)",
12 | "Sebastian Golasch (https://github.com/asciidisco)"
13 | ],
14 | "repository": "lodash/grunt-lodash",
15 | "scripts": {
16 | "test": "echo \"This plugin has been discontinued.\""
17 | },
18 | "engines": {
19 | "node": ">=0.8.19"
20 | },
21 | "dependencies": {
22 | "lodash": "^3.10.1"
23 | },
24 | "peerDependencies": {
25 | "lodash-cli": ">=1.3.1"
26 | },
27 | "files": [
28 | "tasks/lodash.js"
29 | ]
30 | }
31 |
--------------------------------------------------------------------------------
/tasks/lodash.js:
--------------------------------------------------------------------------------
1 | module.exports = function(grunt) {
2 | 'use strict';
3 |
4 | var _ = require('lodash');
5 |
6 | var pkg = require('lodash-cli/package.json'),
7 | bin = pkg.bin.lodash,
8 | builder = require.resolve('lodash-cli/' + bin);
9 |
10 | var customOptions = ['modifier', 'modularize', 'flags', 'shortFlags'];
11 |
12 | var omitCustom = _.partialRight(_.omit, function(value, key) {
13 | return _.contains(customOptions, key);
14 | });
15 |
16 | var push = Array.prototype.push;
17 |
18 | /*--------------------------------------------------------------------------*/
19 |
20 | /** Register the task with Grunt */
21 | grunt.registerMultiTask('lodash', 'Builds a customized lodash', function() {
22 | var done = this.async();
23 |
24 | var options = this.options({
25 | 'modifier': '',
26 | 'flags': [],
27 | 'shortFlags': []
28 | });
29 |
30 | var args = _.map(omitCustom(options), function(value, key) {
31 | if (_.isArray(value)) {
32 | value = value.join(',');
33 | }
34 | return key + '=' + value;
35 | });
36 |
37 | var flags = _.map(options.flags, function(flag) {
38 | return flag.replace(/^(?:--)?/, '--');
39 | });
40 |
41 | var shortFlags = _.map(options.shortFlags, function(flag) {
42 | return flag.replace(/^(?:-)?/, '-');
43 | });
44 |
45 | var spawnArgs = [builder];
46 | if (options.modularize) {
47 | spawnArgs.push('modularize');
48 | }
49 | if (options.modifier) {
50 | push.apply(spawnArgs, [].concat(options.modifier));
51 | }
52 | spawnArgs = spawnArgs.concat(args, flags, shortFlags, '--output', this.files[0].dest);
53 |
54 | grunt.verbose.writeln('lodash-cli version: ' + pkg.version);
55 | grunt.verbose.writeln('Build arguments: ' + spawnArgs.slice(1).join(' '));
56 |
57 | grunt.util.spawn({
58 | 'cmd': 'node',
59 | 'args': spawnArgs
60 | }, function(error, data) {
61 | if (error) {
62 | grunt.log.error(error.toString());
63 | done(error);
64 | }
65 | grunt.verbose.write(data.toString());
66 | done();
67 | });
68 | });
69 | };
70 |
--------------------------------------------------------------------------------