Skip to content

Commit

Permalink
Fix: Ensure autocompletion works (closes #15)
Browse files Browse the repository at this point in the history
  • Loading branch information
heikki authored and phated committed Dec 21, 2017
1 parent a418cdf commit 2146218
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/shared/completion.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = function(name) {
if (typeof name !== 'string') {
throw new Error('Missing completion type');
}
var file = path.join(__dirname, '../completion', name);
var file = path.join(__dirname, '../../completion', name);
try {
console.log(fs.readFileSync(file, 'utf8'));
process.exit(0);
Expand Down
26 changes: 26 additions & 0 deletions test/completion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

var lab = exports.lab = require('lab').script();
var code = require('code');

var child = require('child_process');

lab.experiment('flag: --completion', function () {

['bash', 'fish', 'powershell', 'zsh'].forEach(function(type) {
lab.test('returns completion script for ' + type, function (done) {
child.exec('node ' + __dirname + '/../bin/gulp.js --completion=' + type, function(err, stdout) {
code.expect(stdout).to.contain('gulp --completion=' + type);
done(err);
});
});
});

lab.test('shows error message for unknown completion type', function (done) {
child.exec('node ' + __dirname + '/../bin/gulp.js --completion=unknown', function(err, stdout) {
code.expect(stdout).to.contain('rules for \'unknown\' not found');
done();
});
});

});

0 comments on commit 2146218

Please sign in to comment.