UNPKG

1.92 kBJavaScriptView Raw
1module.exports = function(grunt) {
2 grunt.initConfig({
3 exec: {
4 test1: {
5 cmd: 'echo bruce willis was dead> test1'
6 }
7 , test2: {
8 cmd: function() { return 'echo grunt@' + this.version + '> test2'; }
9 }
10 , test3: {
11 cmd: function(answerToLife, tacoThoughts) {
12 var text = [
13 'the answer to life is ' + answerToLife
14 , 'thoughts on tacos? ' + tacoThoughts
15 ].join(', ');
16
17 return 'echo ' + text + '> test3';
18 }
19 }
20 , test4: {
21 cmd: function(){
22 return 'echo you can use callback, and error, stdout, stderr can be' +
23 ' used as arguments';
24 }
25 , callback: function(error, stdout, stderr){
26 var fs = require('fs')
27 , path = require('path')
28 , outputPath = path.resolve(process.cwd(), 'test4');
29
30 console.log('outputPath : ' + outputPath);
31 console.log('stderr: ' + stderr);
32
33 try {
34 fs.writeFileSync(outputPath, stdout, 'utf-8');
35 } catch (err) {
36 console.error(err.stack);
37 }
38 }
39 }
40 , test5: {
41 cmd: 'node -e "process.exit(8);"'
42 , exitCodes: 8
43 , shell: true
44 }
45 , test6: {
46 cmd: 'node -e "process.exit(9);"'
47 , exitCodes: [8, 9]
48 , shell: true
49 }
50 , test7: 'echo you do not even need an object> test7'
51 , test8: {
52 cmd: 'node -e "console.log(\'synchronous echo 1\'); process.exit(0);"',
53 sync: true,
54 shell: true
55 }
56 , test9: {
57 cmd: 'node -e "setTimeout(function () { console.log(\'synchronous echo 2, wait 3 seconds\'); process.exit(0); }, 3000);"',
58 sync: true,
59 shell: true
60 }
61 , test10: {
62 cmd: 'node -e "console.log(\'synchronous echo 3\'); process.exit(0);"',
63 sync: true,
64 shell: true
65 }
66 }
67 });
68
69 grunt.loadTasks('../tasks');
70};