Skip to content

Commit

Permalink
solidify template branch features
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Escalante committed Dec 17, 2013
1 parent 90b0025 commit d5c08fa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/api/add.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Add extends Base
execute: (opts) ->
configure_options.call(@, opts)
.then(nodefn.lift(exec, "git clone #{@url} #{@path(@name)}"))
.then(=> if @branch then nodefn.call(exec, "git checkout #{@branch}"))
.then(=> if @branch then nodefn.call(exec, "cd #{@path(@name)}; git checkout #{@branch}"))
.yield("template '#{@name}' added")

# @api private
Expand All @@ -28,7 +28,7 @@ class Add extends Base
@url = @name
@name = @url.split('/')[@url.split('/').length-1]

@branch = ''
@branch = null
branch_matcher = /#(.*)$/
if @url.match(branch_matcher)
@branch = "#{@url.match(branch_matcher)[1]}"
Expand Down
13 changes: 13 additions & 0 deletions test/test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ describe 'js api', ->
).then(-> sprout.remove('foobar'))
.done((-> done()), done)

it '[init] creates a project template from a branch', (done) ->
basic_path = path.join(__dirname, 'fixtures/basic')
test_path = path.join(__dirname, 'testproj')

sprout.add(name: 'foobar', url: "#{test_template_url}#alt")
.then(-> sprout.init(template: 'foobar', path: test_path, options: { foo: 'bar' }))
.tap(->
contents = fs.readFileSync(path.join(test_path, 'index.html'), 'utf8')
contents.should.match /alternate/
rm('-rf', test_path)
).then(-> sprout.remove('foobar'))
.done((-> done()), done)

describe 'cli', ->

it '[add] errors when no args provided', ->
Expand Down

0 comments on commit d5c08fa

Please sign in to comment.