Changeset 516 for Dev/trunk/node_modules/grunt-exec
- Timestamp:
- 03/14/14 12:36:58 (11 years ago)
- Location:
- Dev/trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk
- Property svn:ignore
-
old new 1 1 build 2 quod-erat.git
-
- Property svn:ignore
-
Dev/trunk/node_modules/grunt-exec/.travis.yml
r484 r516 1 1 language: node_js 2 2 node_js: 3 - 0.8 3 - "0.8" 4 - "0.10" -
Dev/trunk/node_modules/grunt-exec/Gruntfile.js
r484 r516 10 10 cmd: 'ls -l **' 11 11 } 12 , list_all_files: 'ls -la' 12 13 , echo_grunt_version: { 13 14 cmd: function() { return 'echo ' + this.version; } -
Dev/trunk/node_modules/grunt-exec/README.md
r484 r516 23 23 ----- 24 24 25 This plugin is a [multi task][types_of_tasks], meaning that grunt will automatically iterate over all exec targets if a target is not specified. 25 This plugin is a [multi task][types_of_tasks], meaning that grunt will 26 automatically iterate over all exec targets if a target is not specified. 26 27 27 If the exit code generated by the specified shell command is greater than 0, grunt-exec will assume an error has occurred and will abort grunt immediately. 28 If the exit code generated by the specified shell command is greater than 0, 29 grunt-exec will assume an error has occurred and will abort grunt immediately. 28 30 29 [types_of_tasks]: http s://github.com/gruntjs/grunt/blob/master/docs/types_of_tasks.md#multi-tasks31 [types_of_tasks]: http://gruntjs.com/configuring-tasks#task-configuration-and-targets 30 32 31 33 ### Properties 32 34 33 * __command__: The shell command to be executed. Must be a string or a function that returns a string. (alias: __cmd__) 34 * __stdout__: If `true`, stdout will be printed. Defaults to `true`. 35 * __stderr__: If `true`, stderr will be printed. Defaults to `true`. 36 * __cwd__: Current working directory of the shell command. Defaults to the directory containing your Gruntfile. 37 * __exitCode__: The expected exit code, task will fail if the actual exit code doesn't match. Defaults to `0`. 38 * __callback__: The callback function passed `child_process.exec`. Defaults to a noop. 35 * __command__ (alias: __cmd__): The shell command to be executed. Must be a 36 string or a function that returns a string. 37 * __stdout__: If `true`, stdout will be printed. Defaults to `true`. 38 * __stderr__: If `true`, stderr will be printed. Defaults to `true`. 39 * __cwd__: Current working directory of the shell command. Defaults to the 40 directory containing your Gruntfile. 41 * __exitCode__ (alias: __exitCodes__): The expected exit code(s), task will 42 fail if the actual exit code doesn't match. Defaults to `0`. Can be an array 43 for multiple allowed exit codes. 44 * __callback__: The callback function passed `child_process.exec`. Defaults to 45 a noop. 46 47 If the configuration is instead a simple `string`, it will be 48 interpreted as a full command itself: 49 50 ```javascript 51 exec: { 52 echo_something: 'echo "This is something"' 53 } 54 ``` 39 55 40 56 ### Command Functions 41 57 42 If you plan on doing advanced stuff with grunt-exec, you'll most likely be using functions for the `command` property of your exec targets. This section details a couple of helpful tips about command functions that could help make your life easier. 58 If you plan on doing advanced stuff with grunt-exec, you'll most likely be using 59 functions for the `command` property of your exec targets. This section details 60 a couple of helpful tips about command functions that could help make your life 61 easier. 43 62 44 63 #### Passing arguments from the command line 45 64 46 Command functions can be called with arbitrary arguments. Let's say we have the following exec target that echoes a formatted name: 65 Command functions can be called with arbitrary arguments. Let's say we have the 66 following exec target that echoes a formatted name: 47 67 48 68 ```javascript … … 61 81 ``` 62 82 63 In order to get `SIMPSON, HOMER` echoed, you'd run `grunt exec:echo_name:homer:simpson` from the command line. 83 In order to get `SIMPSON, HOMER` echoed, you'd run 84 `grunt exec:echo_name:homer:simpson` from the command line. 64 85 65 86 ### Accessing `grunt` object 66 87 67 All command functions are called in the context of the `grunt` object that they are being ran with. This means you can access the `grunt` object through `this`. 88 All command functions are called in the context of the `grunt` object that they 89 are being ran with. This means you can access the `grunt` object through `this`. 68 90 69 91 ### Example … … 82 104 cmd: 'ls -l **' 83 105 }, 106 list_all_files: 'ls -la', 84 107 echo_grunt_version: { 85 108 cmd: function() { return 'echo ' + this.version; } … … 117 140 ---------- 118 141 119 For transparency and insight into the release cycle, releases will be numbered with the follow format: 142 For transparency and insight into the release cycle, releases will be numbered 143 with the follow format: 120 144 121 145 `<major>.<minor>.<patch>` -
Dev/trunk/node_modules/grunt-exec/package.json
r484 r516 2 2 "name": "grunt-exec", 3 3 "description": "Grunt task for executing shell commands.", 4 "version": "0.4. 2",4 "version": "0.4.5", 5 5 "homepage": "https://github.com/jharding/grunt-exec", 6 6 "author": { … … 40 40 "shell" 41 41 ], 42 "readme": "[](http://travis-ci.org/jharding/grunt-exec)\ngrunt-exec\n==========\n\nGrunt plugin for executing shell commands.\n\nInstallation\n------------\n\nInstall grunt-exec using npm:\n\n```\n$ npm install grunt-exec\n```\n\nThen add this line to your project's *Gruntfile.js*:\n\n```javascript\ngrunt.loadNpmTasks('grunt-exec');\n```\n\nUsage\n-----\n\nThis plugin is a [multi task][types_of_tasks], meaning that grunt will automatically iterate over all exec targets if a target is not specified.\n\nIf the exit code generated by the specified shell command is greater than 0, grunt-exec will assume an error has occurred and will abort grunt immediately.\n\n[types_of_tasks]: https://github.com/gruntjs/grunt/blob/master/docs/types_of_tasks.md#multi-tasks\n\n### Properties\n\n* __command__: The shell command to be executed. Must be a string or a function that returns a string. (alias: __cmd__)\n* __stdout__: If `true`, stdout will be printed. Defaults to `true`.\n* __stderr__: If `true`, stderr will be printed. Defaults to `true`.\n* __cwd__: Current working directory of the shell command. Defaults to the directory containing your Gruntfile.\n* __exitCode__: The expected exit code, task will fail if the actual exit code doesn't match. Defaults to `0`.\n* __callback__: The callback function passed `child_process.exec`. Defaults to a noop.\n\n### Command Functions\n\nIf you plan on doing advanced stuff with grunt-exec, you'll most likely be using functions for the `command` property of your exec targets. This section details a couple of helpful tips about command functions that could help make your life easier.\n\n#### Passing arguments from the command line\n\nCommand functions can be called with arbitrary arguments. Let's say we have the following exec target that echoes a formatted name:\n\n```javascript\nexec: {\n echo_name: {\n cmd: function(firstName, lastName) {\n var formattedName = [\n lastName.toUpperCase(),\n firstName.toUpperCase()\n ].join(', ');\n\n return 'echo ' + formattedName;\n }\n }\n}\n```\n\nIn order to get `SIMPSON, HOMER` echoed, you'd run `grunt exec:echo_name:homer:simpson` from the command line.\n\n### Accessing `grunt` object\n\nAll command functions are called in the context of the `grunt` object that they are being ran with. This means you can access the `grunt` object through `this`.\n\n### Example\n\nThe following examples are available in grunt-exec's Gruntfile.\n\n```javascript\ngrunt.initConfig({\n exec: {\n remove_logs: {\n command: 'rm -f *.log',\n stdout: false,\n stderr: false\n },\n list_files: {\n cmd: 'ls -l **'\n },\n echo_grunt_version: {\n cmd: function() { return 'echo ' + this.version; }\n },\n echo_name: {\n cmd: function(firstName, lastName) {\n var formattedName = [\n lastName.toUpperCase(),\n firstName.toUpperCase()\n ].join(', ');\n\n return 'echo ' + formattedName;\n }\n }\n }\n});\n```\n\nTesting\n-------\n\n```\n$ cd grunt-exec\n$ npm test\n```\n\nIssues\n------\n\nFound a bug? Create an issue on GitHub.\n\nhttps://github.com/jharding/grunt-exec/issues\n\nVersioning\n----------\n\nFor transparency and insight into the release cycle, releases will be numberedwith the follow format:\n\n`<major>.<minor>.<patch>`\n\nAnd constructed with the following guidelines:\n\n* Breaking backwards compatibility bumps the major\n* New additions without breaking backwards compatibility bumps the minor\n* Bug fixes and misc changes bump the patch\n\nFor more information on semantic versioning, please visit http://semver.org/.\n\nLicense\n-------\n\nCopyright (c) 2012 [Jake Harding](http://thejakeharding.com) \nLicensed under the MIT License.\n",42 "readme": "[](http://travis-ci.org/jharding/grunt-exec)\ngrunt-exec\n==========\n\nGrunt plugin for executing shell commands.\n\nInstallation\n------------\n\nInstall grunt-exec using npm:\n\n```\n$ npm install grunt-exec\n```\n\nThen add this line to your project's *Gruntfile.js*:\n\n```javascript\ngrunt.loadNpmTasks('grunt-exec');\n```\n\nUsage\n-----\n\nThis plugin is a [multi task][types_of_tasks], meaning that grunt will \nautomatically iterate over all exec targets if a target is not specified.\n\nIf the exit code generated by the specified shell command is greater than 0, \ngrunt-exec will assume an error has occurred and will abort grunt immediately.\n\n[types_of_tasks]: http://gruntjs.com/configuring-tasks#task-configuration-and-targets\n\n### Properties\n\n* __command__ (alias: __cmd__): The shell command to be executed. Must be a \n string or a function that returns a string.\n* __stdout__: If `true`, stdout will be printed. Defaults to `true`.\n* __stderr__: If `true`, stderr will be printed. Defaults to `true`.\n* __cwd__: Current working directory of the shell command. Defaults to the \n directory containing your Gruntfile.\n* __exitCode__ (alias: __exitCodes__): The expected exit code(s), task will \n fail if the actual exit code doesn't match. Defaults to `0`. Can be an array \n for multiple allowed exit codes.\n* __callback__: The callback function passed `child_process.exec`. Defaults to \n a noop.\n\nIf the configuration is instead a simple `string`, it will be\ninterpreted as a full command itself:\n\n```javascript\nexec: {\n echo_something: 'echo \"This is something\"'\n}\n```\n\n### Command Functions\n\nIf you plan on doing advanced stuff with grunt-exec, you'll most likely be using \nfunctions for the `command` property of your exec targets. This section details \na couple of helpful tips about command functions that could help make your life \neasier.\n\n#### Passing arguments from the command line\n\nCommand functions can be called with arbitrary arguments. Let's say we have the \nfollowing exec target that echoes a formatted name:\n\n```javascript\nexec: {\n echo_name: {\n cmd: function(firstName, lastName) {\n var formattedName = [\n lastName.toUpperCase(),\n firstName.toUpperCase()\n ].join(', ');\n\n return 'echo ' + formattedName;\n }\n }\n}\n```\n\nIn order to get `SIMPSON, HOMER` echoed, you'd run \n`grunt exec:echo_name:homer:simpson` from the command line.\n\n### Accessing `grunt` object\n\nAll command functions are called in the context of the `grunt` object that they \nare being ran with. This means you can access the `grunt` object through `this`.\n\n### Example\n\nThe following examples are available in grunt-exec's Gruntfile.\n\n```javascript\ngrunt.initConfig({\n exec: {\n remove_logs: {\n command: 'rm -f *.log',\n stdout: false,\n stderr: false\n },\n list_files: {\n cmd: 'ls -l **'\n },\n list_all_files: 'ls -la',\n echo_grunt_version: {\n cmd: function() { return 'echo ' + this.version; }\n },\n echo_name: {\n cmd: function(firstName, lastName) {\n var formattedName = [\n lastName.toUpperCase(),\n firstName.toUpperCase()\n ].join(', ');\n\n return 'echo ' + formattedName;\n }\n }\n }\n});\n```\n\nTesting\n-------\n\n```\n$ cd grunt-exec\n$ npm test\n```\n\nIssues\n------\n\nFound a bug? Create an issue on GitHub.\n\nhttps://github.com/jharding/grunt-exec/issues\n\nVersioning\n----------\n\nFor transparency and insight into the release cycle, releases will be numbered \nwith the follow format:\n\n`<major>.<minor>.<patch>`\n\nAnd constructed with the following guidelines:\n\n* Breaking backwards compatibility bumps the major\n* New additions without breaking backwards compatibility bumps the minor\n* Bug fixes and misc changes bump the patch\n\nFor more information on semantic versioning, please visit http://semver.org/.\n\nLicense\n-------\n\nCopyright (c) 2012 [Jake Harding](http://thejakeharding.com) \nLicensed under the MIT License.\n", 43 43 "readmeFilename": "README.md", 44 "_id": "grunt-exec@0.4. 2",44 "_id": "grunt-exec@0.4.5", 45 45 "dist": { 46 "shasum": " 021f0dddaeef00cc4d83dff9d0d8c47a64917dbd"46 "shasum": "2848b5f9ed0a096b459a637aad35cc89098b7958" 47 47 }, 48 "_from": "grunt-exec@0.4. 2",49 "_resolved": "https://registry.npmjs.org/grunt-exec/-/grunt-exec-0.4. 2.tgz"48 "_from": "grunt-exec@0.4.5", 49 "_resolved": "https://registry.npmjs.org/grunt-exec/-/grunt-exec-0.4.5.tgz" 50 50 } -
Dev/trunk/node_modules/grunt-exec/tasks/exec.js
r484 r516 18 18 , stderr = data.stderr !== undefined ? data.stderr : true 19 19 , callback = _.isFunction(data.callback) ? data.callback : function() {} 20 , exitCode = data.exitCode|| 020 , exitCodes = data.exitCode || data.exitCodes || 0 21 21 , command 22 22 , childProcess … … 24 24 , done = this.async(); 25 25 26 // https://github.com/jharding/grunt-exec/pull/30 27 exitCodes = _.isArray(exitCodes) ? exitCodes : [exitCodes]; 28 26 29 // allow for command to be specified in either 27 // 'command' or 'cmd' property 28 command = data.command || data.cmd ;30 // 'command' or 'cmd' property, or as a string. 31 command = data.command || data.cmd || (_.isString(data) && data); 29 32 30 33 data.cwd && (execOptions.cwd = data.cwd); … … 46 49 47 50 verbose.subhead(command); 48 verbose.writeln(f('Expecting exit code % d', exitCode));51 verbose.writeln(f('Expecting exit code %s', exitCodes.join(' or '))); 49 52 50 53 childProcess = cp.exec(command, execOptions, callback); … … 54 57 55 58 childProcess.on('exit', function(code) { 56 if ( code !== exitCode) {59 if (exitCodes.indexOf(code) < 0) { 57 60 log.error(f('Exited with code: %d.', code)); 58 61 return done(false); -
Dev/trunk/node_modules/grunt-exec/test/Gruntfile.js
r484 r516 21 21 cmd: function(){ 22 22 return 'echo "you can use callback, and error, stdout, stderr can be used as arguments"'; 23 }, 24 callback: function(error, stdout, stderr){ 25 var fs = require('fs'); 26 var path = require('path'); 27 var outputPath = path.resolve(process.cwd(), 'test4'); 23 } 24 , callback: function(error, stdout, stderr){ 25 var fs = require('fs') 26 , path = require('path') 27 , outputPath = path.resolve(process.cwd(), 'test4'); 28 28 29 console.log('outputPath : ' + outputPath); 29 30 fs.writeFileSync(outputPath, stdout, 'utf-8'); 30 31 } 31 32 } 33 , test5: { 34 cmd: 'exit 8' 35 , exitCodes: 8 36 } 37 , test6: { 38 cmd: 'exit 9' 39 , exitCodes: [8, 9] 40 } 41 , test7: 'echo "you don\'t even need an object" > test7' 32 42 } 33 43 }); -
Dev/trunk/node_modules/grunt-exec/test/test.js
r484 r516 5 5 , testDir = path.join(process.cwd(), 'test') 6 6 , opts = { gruntfile: path.join(testDir, 'Gruntfile.js') } 7 , tasks = ['exec:test1', 'exec:test2', 'exec:test3:42:love', 'exec:test4']; 7 , tasks = [ 8 'exec:test1' 9 , 'exec:test2' 10 , 'exec:test3:42:love' 11 , 'exec:test4' 12 , 'exec:test5' 13 , 'exec:test6' 14 , 'exec:test7' 15 ]; 8 16 9 17 grunt.tasks(tasks, opts, function() { … … 21 29 , expected:'you can use callback, and error, stdout, stderr can be used as arguments\n' 22 30 } 31 , { name: 'test7', expected: 'you don\'t even need an object\n' } 23 32 ] 24 33 , outputPath;
Note: See TracChangeset
for help on using the changeset viewer.