|
2 | 2 |
|
3 | 3 | > A grunt task to ensure you are using the node version required by your project's package.json |
4 | 4 |
|
5 | | -#### More info will be available here once the package is released.... |
| 5 | +## Getting Started |
| 6 | +This plugin requires Grunt `~0.4.1` and Node.js `>=0.12.14`. |
6 | 7 |
|
7 | | -Requires node >=0.12.14 |
| 8 | +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: |
8 | 9 |
|
9 | | -*Forked from [grunt-node-version](https://github.com/jking90/grunt-node-version) by Jimmy King* |
| 10 | +```shell |
| 11 | +npm install grunt-node-version-windows --save-dev |
| 12 | +``` |
| 13 | + |
| 14 | +Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript: |
| 15 | + |
| 16 | +```js |
| 17 | +grunt.loadNpmTasks('grunt-node-version-windows'); |
| 18 | +``` |
| 19 | + |
| 20 | + |
| 21 | +## The "node_version" task |
| 22 | + |
| 23 | +### Overview |
| 24 | +In your project's Gruntfile, add a section named `node_version` to the data object passed into `grunt.initConfig()`. |
| 25 | + |
| 26 | +```js |
| 27 | +grunt.initConfig({ |
| 28 | + node_version: { |
| 29 | + options: { |
| 30 | + alwaysInstall: false, |
| 31 | + errorLevel: 'fatal', |
| 32 | + globals: [], |
| 33 | + nvm: true, |
| 34 | + override: "", |
| 35 | + debug: false |
| 36 | + } |
| 37 | + } |
| 38 | +}) |
| 39 | +``` |
| 40 | + |
| 41 | +### Options |
| 42 | + |
| 43 | +#### options.alwaysInstall |
| 44 | +Type: `Boolean` |
| 45 | +Default value: `false` |
| 46 | + |
| 47 | +A boolean that determines whether to install the latest compatible version of node without a prompt (default behavior prompts user to install). This is primarily intended to be used for deployment. |
| 48 | + |
| 49 | +#### options.errorLevel |
| 50 | +Type: `String` |
| 51 | +Default value: `'fatal'` |
| 52 | + |
| 53 | +The level of error given when the wrong node version is being used. Accepted values are `'warn'` and `'fatal'`. Warn can can be overidden with `--force`, fatal cannot. |
| 54 | + |
| 55 | +#### options.globals |
| 56 | +Type: `Array` |
| 57 | +Default value: `[]` |
| 58 | + |
| 59 | +An array of node modules required to be installed globally for the project. |
| 60 | + |
| 61 | +#### options.nvm |
| 62 | +Type: `Boolean` |
| 63 | +Default value: `true` |
| 64 | + |
| 65 | +A boolean that determines whether to attempt to use/install a version of node compatible with the project using [nvm-windows](https://github.com/coreybutler/nvm-windows). If set to `false`, the plugin will just print an error if the wrong node version is being used. |
| 66 | + |
| 67 | +#### options.override |
| 68 | +Type: `String` |
| 69 | +Default value: `''` |
| 70 | + |
| 71 | +If you want to override the version specified in your project's `package.json`, specify the version you want to use instead here. This is primarily intended for testing projects on other versions of node. |
| 72 | + |
| 73 | +#### options.debug |
| 74 | +Type: `Boolean` |
| 75 | +Default value: `false` |
| 76 | + |
| 77 | +A boolean that turns detailed logging on / off. If set to `true`, a message will be logged to the console each time a new command is executed. This is primarily used for debugging issues and testing. |
| 78 | + |
| 79 | +##### This plugin only works on Windows and with nvm-windows. |
| 80 | + |
| 81 | +*Forked from [grunt-node-version](https://github.com/jking90/grunt-node-version) by Jimmy King.* |
0 commit comments