Created
July 13, 2014 13:40
-
-
Save jakecraige/70c8a8583cd765cc1332 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var Promise = require('../../lib/ext/promise'); | |
var Task = require('../models/task'); | |
var exec = Promise.denodeify(require('child_process').exec); | |
var fs = require('fs'); | |
var path = require('path'); | |
var _ = require('lodash-node'); | |
var commitTemplate = fs.readFileSync(path.join(__dirname, '../utilities/COMMIT_MESSAGE.txt')); | |
module.exports = Task.extend({ | |
run: function(commandOptions) { | |
var noop = function(){}; | |
var chalk = require('chalk'); | |
var ui = this.ui; | |
if(commandOptions.skipGit) { return Promise.resolve(); } | |
return exec('git init').then(noop, function() { | |
ui.write(chalk.yellow('Something went wrong with git init.')); | |
}).then(function() { | |
return exec('git add .'); | |
}).then(noop, function(){ | |
ui.write(chalk.yellow('Something went wrong with git add')); | |
}).then(function(){ | |
console.log(this.project.pkg); | |
var commitMessage = _.template(commitTemplate, this.project.pkg); | |
return exec('git commit -m "' + commitMessage + '"'); | |
}.bind(this)).then(noop, function(){ | |
ui.write(chalk.yellow('Something went wrong with git commit')); | |
}).then(function(){ | |
ui.write(chalk.green('Sucessfully initialized git')); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment