ace3cd580e9a77e4bf9bdd26ec62d65eea7a050b
[yaffs-website] / node_modules / grunt / node_modules / grunt-cli / lib / completion.js
1 /*
2  * grunt-cli
3  * http://gruntjs.com/
4  *
5  * Copyright (c) 2016 Tyler Kellen, contributors
6  * Licensed under the MIT license.
7  * https://github.com/gruntjs/grunt-init/blob/master/LICENSE-MIT
8  */
9
10 'use strict';
11
12 // Nodejs libs.
13 var fs = require('fs');
14 var path = require('path');
15
16 exports.print = function(name) {
17   var code = 0;
18   var filepath = path.join(__dirname, '../completion', name);
19   var output;
20   try {
21     // Attempt to read shell completion file.
22     output = String(fs.readFileSync(filepath));
23   } catch (err) {
24     code = 5;
25     output = 'echo "Specified grunt shell auto-completion rules ';
26     if (name && name !== 'true') {
27       output += 'for \'' + name + '\' ';
28     }
29     output += 'not found."';
30   }
31
32   console.log(output);
33   process.exit(code);
34 };