[484] | 1 | grunt-amd-check |
---|
| 2 | =============== |
---|
| 3 | |
---|
| 4 | grunt-amd-check is a [grunt](http://gruntjs.com/) multitask to check for |
---|
| 5 | broken AMD dependencies in a project. |
---|
| 6 | |
---|
| 7 | This plugin requires Grunt `~0.4.0` |
---|
| 8 | |
---|
| 9 | |
---|
| 10 | Installation |
---|
| 11 | ------------- |
---|
| 12 | |
---|
| 13 | From the same directory as your Gruntfile, run |
---|
| 14 | |
---|
| 15 | ``` |
---|
| 16 | npm install grunt-amd-check |
---|
| 17 | ``` |
---|
| 18 | |
---|
| 19 | Then add the following line to your Gruntfile: |
---|
| 20 | |
---|
| 21 | ```js |
---|
| 22 | grunt.loadNpmTasks('grunt-amd-check'); |
---|
| 23 | ``` |
---|
| 24 | |
---|
| 25 | You can verify that the task is available by running `grunt --help` and |
---|
| 26 | checking that "amd-check" is under "Available tasks". |
---|
| 27 | |
---|
| 28 | |
---|
| 29 | Configuration |
---|
| 30 | ------------- |
---|
| 31 | |
---|
| 32 | grunt-amd-check reads two sections of your config: `amd-check` and |
---|
| 33 | `requirejs`. `amd-check` can contain these properties (example from |
---|
| 34 | [class.js](https://github.com/zship/class.js)): |
---|
| 35 | |
---|
| 36 | ```js |
---|
| 37 | 'amd-check': { |
---|
| 38 | //Grunt files configuration object for which to trace dependencies |
---|
| 39 | //(more: http://gruntjs.com/configuring-tasks) |
---|
| 40 | files: ['src/**/*.js', 'test/spec/**/*.js'] |
---|
| 41 | }, |
---|
| 42 | ``` |
---|
| 43 | |
---|
| 44 | `requirejs` is a standard [r.js configuration |
---|
| 45 | object](https://github.com/jrburke/r.js/blob/master/build/example.build.js). |
---|
| 46 | grunt-amd-check uses `basePath`, `paths`, and `packages` (all optional) |
---|
| 47 | to transform AMD module names to absolute file names. If the `mainConfigFile` |
---|
| 48 | property is given, the configuration in that file will be mixed-in to the |
---|
| 49 | `requirejs` property with a **lower** precedence (that is, in the case of a |
---|
| 50 | conflicting configuration property, `requirejs` will always "win" against |
---|
| 51 | `mainConfigFile`). |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | Tasks |
---|
| 55 | ----- |
---|
| 56 | |
---|
| 57 | ### amd-check |
---|
| 58 | |
---|
| 59 | `grunt amd-check` iterates through all files matched in the `files` option and |
---|
| 60 | reports any dependencies which cannot be resolved to absolute paths. |
---|
| 61 | |
---|
| 62 | ### whatrequires |
---|
| 63 | |
---|
| 64 | `grunt whatrequires` accepts a single argument `searchFile` and iterates |
---|
| 65 | through all files matched in the `files` option, looking for modules which list |
---|
| 66 | `searchFile` as a dependency (in any valid RequireJS format). _Note: Grunt |
---|
| 67 | denotes arguments using a ":" character after the task name, followed by the |
---|
| 68 | argument._ |
---|
| 69 | |
---|
| 70 | Example: `grunt whatrequires:src/js/BaseController.js` might report |
---|
| 71 | `src/js/HomeController.js` and `src/js/NavigationController.js` as dependents. |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | License |
---|
| 75 | ------- |
---|
| 76 | |
---|
| 77 | Released under the [MIT |
---|
| 78 | License](http://www.opensource.org/licenses/mit-license.php). |
---|