source: Dev/trunk/node_modules/grunt-svninfo/README.md @ 533

Last change on this file since 533 was 516, checked in by hendrikvanantwerpen, 11 years ago

Enable deployment with Grunt.

File size: 3.9 KB
RevLine 
[516]1# grunt-svninfo
2
3> A Grunt.js plugin that provides easy access to Subversion working copy metadata (svn info).
4
5## Getting Started
6This plugin requires Grunt `~0.4.0`
7
8If 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:
9
10```shell
11npm install grunt-svninfo --save-dev
12```
13
14One the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
15
16```js
17grunt.loadNpmTasks('grunt-svninfo');
18```
19
20That's about it, no configuration necessary.
21
22## The "svninfo" task
23
24### Overview
25In your project's Gruntfile, add a section named `svninfo` to the data object passed into `grunt.initConfig()`.
26Executing the task `svninfo` would run `svn info` in the command line and would make the retrieved data available via grunt.config (e.g. `<%= svninfo.rev %>`) in your build.
27The resulting `svninfo` object has the following structure:
28
29
30```js
31{
32  "rev": "321",
33  "url": "https://yourproject.unfuddle.com/svn/repo/trunk",
34  "last": {
35          "rev": "321",
36          "author": "me",
37          "date": "2013-02-10 12:35:30 +0200"
38  },
39  "repository": {
40          "root": "https://yourproject.unfuddle.com/svn/repo",
41          "id": "f5d41312-1fa6-4ca6-a93e-e27d7e98fc43"
42  }
43}
44```
45
46### Options
47
48#### cwd
49Type: `String`
50
51Allows to specify a cwd (current working directory) path for the SVN repository of which to retrieve the information. The default directory is the where you run grunt from (`'.'`).
52
53Example:
54``` js
55svninfo: {
56  options: {
57    cwd: './myproject/ishere'
58  },
59  ...
60}
61```
62
63#### output
64Type: `String`
65
66Allows to specify a custom object that would contain the retrieved and parsed SVN info. Defaults to 'svninfo'. This feature came about to support projects with multiple external dependencies ("extenals"), in which each external would have its own info object instead of having them override each other with each 'info' call.
67
68Name of object can be redefined or specified by the first argument of task (see below).
69
70Example:
71``` js
72svninfo: {
73  options: {
74    output: 'myExternal_svninfo'
75  },
76  ...
77}
78```
79
80#### args
81Type: `Array`
82
83Allows to specify options for `svn info` command (e.g. target, username, password etc).
84
85Example:
86``` js
87svninfo: {
88  options: {
89    args: ['http://some.svn-server.net/repo/project/trunk', '--username', 'name', '--password', 'pass']
90  },
91  ...
92}
93```
94
95It is possible to retrieve command options from other option instead of `args`.
96It can be done by using the second argument of task (see below).
97
98### Task arguments
99
100Two arguments can be passed to the task:
101
1021. Allows to specify a custom object that would contain the retrieved and parsed SVN info. This argument has priority over the `output` option.
1032. Allows to specify name of options field that contains list of command options. This argument has priority over the `args` option.
104
105Example:
106``` js
107grunt.initConfig({
108  svninfo: {
109    options: {
110      abcArgs: ['http://some.svn-server.net/repo/abc/trunk', '--username', 'name', '--password', 'pass']
111    },
112    ...
113  }
114...
115grunt.registerTask("abcInfo", ["svninfo:abc:abcArgs"]);
116// or `grunt svninfo:abc:abcArgs` from command line
117});
118```
119
120## Contributing
121In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).
122
123## Release History
124 * 0.1.4 - Support for task arguments and args option (thanks to @gamtiq)
125 * 0.1.3 - Support for a custom name for the info object (thanks to @solomojb)
126 * 0.1.2 - Support for 'cwd' option (thanks to @richmarr)
127 * 0.1.1 - Grunt 0.4.x compatibility
128 * 0.1.0 - Initial release
Note: See TracBrowser for help on using the repository browser.