Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix windows tests #4

Merged
merged 4 commits into from
Dec 28, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var cli = new Liftoff({
var failed = false;
process.once('exit', function(code) {
if (code === 0 && failed) {
process.exit(1);
exit(1);
}
});

Expand Down Expand Up @@ -78,7 +78,7 @@ function handleArguments(env) {
if (env.modulePackage && typeof env.modulePackage.version !== 'undefined') {
gutil.log('Local version', env.modulePackage.version);
}
process.exit(0);
exit(0);
}

if (!env.modulePath) {
Expand All @@ -87,12 +87,12 @@ function handleArguments(env) {
chalk.magenta(tildify(env.cwd))
);
gutil.log(chalk.red('Try running: npm install gulp'));
process.exit(1);
exit(1);
}

if (!env.configPath) {
gutil.log(chalk.red('No gulpfile found'));
process.exit(1);
exit(1);
}

// check for semver difference between cli and local installation
Expand Down Expand Up @@ -207,6 +207,17 @@ function logEvents(gulpInst) {
chalk.red('Task \'' + err.task + '\' is not in your gulpfile')
);
gutil.log('Please check the documentation for proper gulpfile formatting');
process.exit(1);
exit(1);
});
}

// fix stdout truncation on windows
function exit(code) {
if (process.platform === 'win32' && process.stdout.bufferSize) {
process.stdout.once('drain', function() {
process.exit(code);
});
return;
}
process.exit(code);
}
4 changes: 2 additions & 2 deletions test/flags-task-simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ var code = require('code');
var fs = require('fs');
var child = require('child_process');

var output = fs.readFileSync(__dirname + '/expected/flags-tasks-simple.txt', 'utf8');
var output = fs.readFileSync(__dirname + '/expected/flags-tasks-simple.txt', 'utf8').replace(/\r\n/g, '\n');

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

lab.test('prints the task list', function (done) {
child.exec(__dirname + '/../index.js --tasks-simple --cwd ./test', function(err, stdout) {
child.exec('node ' + __dirname + '/../index.js --tasks-simple --cwd ./test', function(err, stdout) {
code.expect(stdout).to.equal(output);
done(err);
});
Expand Down
3 changes: 2 additions & 1 deletion test/flags-tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ var child = require('child_process');
lab.experiment('flag: --tasks', function () {

lab.test('prints the task list', function (done) {
child.exec(__dirname + '/../index.js --tasks --cwd ./test', function(err, stdout) {
child.exec('node ' + __dirname + '/../index.js --tasks --cwd ./test', function(err, stdout) {
stdout = stdout.replace(/\\/g, '/');
code.expect(stdout).to.contain('/gulp-cli/test');
code.expect(stdout).to.contain('├── test1');
code.expect(stdout).to.contain('├── test2');
Expand Down
2 changes: 1 addition & 1 deletion test/flags-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var gulpVersion = require('gulp/package.json').version;
lab.experiment('flag: --version', function () {

lab.test('prints the task list', function (done) {
child.exec(__dirname + '/../index.js --version --cwd ./test', function(err, stdout) {
child.exec('node ' + __dirname + '/../index.js --version --cwd ./test', function(err, stdout) {
code.expect(stdout).to.contain('CLI version ' + cliVersion);
code.expect(stdout).to.contain('Local version ' + gulpVersion);
done(err);
Expand Down