-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert to a promise-based interface
- Loading branch information
Jeff Escalante
committed
Dec 17, 2013
1 parent
149379f
commit 94b7ba6
Showing
14 changed files
with
148 additions
and
216 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
which = require 'which' | ||
W = require 'when' | ||
nodefn = require 'when/node/function' | ||
exec = require('child_process').exec | ||
Base = require '../base' | ||
|
||
class Add extends Base | ||
|
||
constructor: -> super | ||
|
||
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}")) | ||
.yield("template '#{@name}' added") | ||
|
||
# @api private | ||
|
||
configure_options = (opts) -> | ||
if not opts then return W.reject('your template needs a name!') | ||
@name = opts.name | ||
@url = opts.url | ||
|
||
if not @name then return W.reject('your template needs a name!') | ||
if not which.sync('git') then return W.reject('you need to have git installed') | ||
|
||
if @name and not @url | ||
@url = @name | ||
@name = @url.split('/')[@url.split('/').length-1] | ||
|
||
@branch = '' | ||
branch_matcher = /#(.*)$/ | ||
if @url.match(branch_matcher) | ||
@branch = "#{@url.match(branch_matcher)[1]}" | ||
@url = @url.replace(branch_matcher, '') | ||
|
||
W.resolve() | ||
|
||
module.exports = (opts) -> | ||
(new Add()).execute(opts) |
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
rimraf = require 'rimraf' | ||
Base = require '../base' | ||
nodefn = require 'when/node/function' | ||
|
||
class Remove extends Base | ||
|
||
constructor: -> super | ||
|
||
execute: (name) -> | ||
nodefn.call(rimraf, @path(name)) | ||
.yield("template '#{name}' removed") | ||
|
||
module.exports = (name) -> | ||
(new Remove()).execute(name) |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Base = require('./base') | ||
base = new Base | ||
|
||
module.exports = require('./commands') | ||
module.exports = require('./api') | ||
module.exports.path = base.path.bind(base) |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.