completion.js 486 B

12345678910111213141516171819202122
  1. 'use strict';
  2. var fs = require('fs');
  3. var path = require('path');
  4. module.exports = function(name) {
  5. if (typeof name !== 'string') {
  6. throw new Error('Missing completion type');
  7. }
  8. var file = path.join(__dirname, '../../completion', name);
  9. try {
  10. console.log(fs.readFileSync(file, 'utf8'));
  11. process.exit(0);
  12. } catch (err) {
  13. console.log(
  14. 'echo "gulp autocompletion rules for',
  15. '\'' + name + '\'',
  16. 'not found"'
  17. );
  18. process.exit(5);
  19. }
  20. };