Skip to content

Instantly share code, notes, and snippets.

@munro
Forked from anonymous/update.js.coffee
Last active August 29, 2015 14:05
Show Gist options
  • Save munro/1d7c3cec7da604ea31a3 to your computer and use it in GitHub Desktop.
Save munro/1d7c3cec7da604ea31a3 to your computer and use it in GitHub Desktop.
fetchDependencies: (version, value) ->
promises = []
for x in version.dependencies
promise = @searchTerm(x.name).then (data) =>
d = _.first(data)
dep_search = _.last(d.versions)
if dep_search.scripts.length > 0
el = document.createElement("script")
el.setAttribute("data-require", value.name + "@*")
el.setAttribute("data-semver", version.semver)
el.setAttribute("src", version.scripts)
return el
console.log @arr, 'script'
else if dep_search.styles.length > 0
el = document.createElement("styles")
el.setAttribute("data-require", value.name + "@~" + version.semver)
el.setAttribute("data-semver", version.semver)
el.setAttribute("src", version.styles)
return el
promises.push(promise)
$q.all(promises)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment