Skip to content

Commit

Permalink
Update istatic.js
Browse files Browse the repository at this point in the history
支持grunt-istatic的异步回调
  • Loading branch information
dexteryy committed Feb 19, 2013
1 parent 1303a91 commit ca178d0
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions istatic.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ function pullAction(config) {
function copyAfterReset(name) {
repo = repos[name]
commit = repo.tag || repo.commit
reset(name, commit).done(function() {
return reset(name, commit).done(function() {
process.chdir(cwd)
copy2app(name, repos[name].file)
})
Expand All @@ -320,6 +320,8 @@ function pullAction(config) {
return fs.existsSync(repo)
}

var promises = []

for (var name in repos) {
(function(name) {
repo = repos[name]
Expand All @@ -337,27 +339,29 @@ function pullAction(config) {
normalizeName(src)), normalizeName(files[src]))
}

fetch(name).done(function() {
copyAfterReset(name)
})
promises.push(fetch(name).done(function() {
return copyAfterReset(name)
}).follow())
} else {
 clone(repoUrl, repoPath).done(function() {
copyAfterReset(name)
})
 promises.push(clone(repoUrl, repoPath).done(function() {
return copyAfterReset(name)
}).follow())
}
})(name)
}

return eventMaster.when.apply(this, promises)
}

function pull(config) {
function pull(config, cb) {
makeTempGitReposDir()
if (config) { return pullAction(config) }
if (config) { return pullAction(config).then(cb) }

getConfigFile('static.yaml')
.done(pullAction)
.fail(function(err) {
logger.error(err)
})
}).follow().then(cb)
}

function clear(name) {
Expand Down

0 comments on commit ca178d0

Please sign in to comment.