Skip to content

Commit

Permalink
feedback clean up commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle MacDonald committed Mar 25, 2014
1 parent b68ceba commit 96a38b2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bin/sprout
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var argv = require('optimist').argv,
commands = require('../lib/api');

// add sprout.new alias
commands['new'] = function() { return undefined; };
commands['new'] = function(){};

// get command
var name = argv._.splice(0,1)[0];
Expand Down
13 changes: 7 additions & 6 deletions lib/api/add.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exec = require('child_process').exec
Base = require '../base'
fs = require 'fs'
path = require 'path'
rimraf = require 'rimraf'
url = require 'url'

class Add extends Base
Expand All @@ -18,7 +19,7 @@ class Add extends Base
.then(set_branch)
.then(remove_existing_template)
.then(link_project)
.then(handle_branch_checkout)
.then(checkout_branch)
.yield("template '#{@name}' added")

# @api private
Expand Down Expand Up @@ -49,10 +50,10 @@ class Add extends Base
ensure_local_template_exists = ->
if not @local then return W.resolve()
if not which.sync('git')
throw W.reject('you need to have git installed')
return W.reject('you need to have git installed')

if not fs.existsSync(path.normalize(@template))
throw W.reject("there is no sprout template located at '#{@template}'")
return W.reject("there is no sprout template located at '#{@template}'")

set_branch = ->
if @local then return W.resolve()
Expand All @@ -64,16 +65,16 @@ class Add extends Base
W.resolve()

remove_existing_template = ->
nodefn.call(exec, "rm -rf #{@path(@name)}")
nodefn.call(rimraf, @path(@name))

link_project = ->
cmd = "git clone #{@template} #{@path(@name)}"
if @local then cmd = "rm -rf #{@path(@name)} && ln -s #{@template} #{@path(@name)}"
nodefn.call(exec, cmd)

handle_branch_checkout = ->
checkout_branch = ->
if not @branch then return W.resolve()
nodefn.call(exec, "cd #{@path(@name)}; git checkout #{@branch}")
nodefn.call(exec, "git checkout #{@branch}", {cwd: @path(@name)})

module.exports = (opts) ->
(new Add()).execute(opts)
4 changes: 2 additions & 2 deletions lib/api/init.coffee
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
path = require 'path'
fs = require 'fs'
W = require 'when'
nodefn = require 'when/node/function'
nodefn = require 'when/node'
nodecb = require 'when/callbacks'
readdirp = require 'readdirp'
ncp = require('ncp').ncp
Expand Down Expand Up @@ -47,6 +47,7 @@ class Init extends Base
@target = opts.path
@options = opts.options
@sprout_path = @path(@name)
@answers = {}

if not fs.existsSync(@sprout_path)
return W.reject("template '#{@name}' does not exist")
Expand All @@ -69,7 +70,6 @@ class Init extends Base
@questions = _.reject(@config.configure, (v) -> _.contains(keys, v.name) )

prompt_user_for_answers = ->
@answers = {}
if not @questions.length then return W.resolve()
nodecb.call(inquirer.prompt, @questions)
.then((o) => @answers = o)
Expand Down
1 change: 0 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,4 @@ We also provide you the power of [String.js](http://stringjs.com/) in all of you
class <%= S('user_model').capialize().s; %> // given 'user_model' is prompted by your init.coffee
```


So between this config file and the root folder, you should be able to make anything happen fairly easily. If not, please open up and issue and we'll try to make it happening-er and/or easier for you : )

0 comments on commit 96a38b2

Please sign in to comment.