var _ = require('lodash');
var jsonfile = require('jsonfile');
var thenify = require('thenify');
var args = require('yargs')
	.alias('v', 'version')
	.argv;

var readJson = thenify(jsonfile.readFile);
var writeJson = thenify(jsonfile.writeFile);

var packageFile = 'package.json';

exports.config = function(gulp) {
	if (_.isUndefined(gulp)) {
		gulp = require('gulp');
	}

	gulp.task('version', (done) => {
		var versionStr = args.version;
		return exports.version(versionStr)
			.then(() => {
				console.log('Version changed to ' + versionStr);
				done();
			})
			.catch(err => done(err));
	});
};

exports.version = (version) => {
	return readJson(packageFile)
		.then(package => {
			package.version = version;
			return writeJson(packageFile, package, { spaces: 2 });
		});
};

var _ = require('lodash');
var jsonfile = require('jsonfile');
var thenify = require('thenify');
var args = require('yargs')
	.alias('v', 'version')
	.argv;

var readJson = thenify(jsonfile.readFile);
var writeJson = thenify(jsonfile.writeFile);

var packageFile = 'package.json';

exports.config = function(gulp) {
	if (_.isUndefined(gulp)) {
		gulp = require('gulp');
	}

	gulp.task('version', () => {
		var versionStr = args.version;
		return exports.version(versionStr)
			.then(() => {
				console.log('Version changed to ' + versionStr);
			});
	});
};

exports.version = (version) => {
	return readJson(packageFile)
		.then(package => {
			package.version = version;
			return writeJson(packageFile, package, { spaces: 2 });
		});
};

Return promise instead of done
Return promise instead of done

It appears that if you return a promise to gulp, gulp waits on the promise and catches the failed promise. By return the promise AND calling done, task completion was getting called twice.
