Skip to content

Commit 2146218

Browse files
heikkiphated
authored andcommitted
Fix: Ensure autocompletion works (closes #15)
1 parent a418cdf commit 2146218

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

lib/shared/completion.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = function(name) {
77
if (typeof name !== 'string') {
88
throw new Error('Missing completion type');
99
}
10-
var file = path.join(__dirname, '../completion', name);
10+
var file = path.join(__dirname, '../../completion', name);
1111
try {
1212
console.log(fs.readFileSync(file, 'utf8'));
1313
process.exit(0);

test/completion.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict';
2+
3+
var lab = exports.lab = require('lab').script();
4+
var code = require('code');
5+
6+
var child = require('child_process');
7+
8+
lab.experiment('flag: --completion', function () {
9+
10+
['bash', 'fish', 'powershell', 'zsh'].forEach(function(type) {
11+
lab.test('returns completion script for ' + type, function (done) {
12+
child.exec('node ' + __dirname + '/../bin/gulp.js --completion=' + type, function(err, stdout) {
13+
code.expect(stdout).to.contain('gulp --completion=' + type);
14+
done(err);
15+
});
16+
});
17+
});
18+
19+
lab.test('shows error message for unknown completion type', function (done) {
20+
child.exec('node ' + __dirname + '/../bin/gulp.js --completion=unknown', function(err, stdout) {
21+
code.expect(stdout).to.contain('rules for \'unknown\' not found');
22+
done();
23+
});
24+
});
25+
26+
});

0 commit comments

Comments
 (0)