From d5c08fa0ec50213ec2abc3e5c9fb183aefa78aa0 Mon Sep 17 00:00:00 2001 From: Jeff Escalante Date: Tue, 17 Dec 2013 16:27:38 -0500 Subject: [PATCH] solidify template branch features --- lib/api/add.coffee | 4 ++-- test/test.coffee | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/api/add.coffee b/lib/api/add.coffee index 9781ba6..73b96e7 100644 --- a/lib/api/add.coffee +++ b/lib/api/add.coffee @@ -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 @@ -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]}" diff --git a/test/test.coffee b/test/test.coffee index 9c77a3e..20e8d9d 100644 --- a/test/test.coffee +++ b/test/test.coffee @@ -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', ->