Skip to content

Instantly share code, notes, and snippets.

@othiym23

othiym23/xmpl.js Secret

Created June 6, 2013 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save othiym23/c080e9f5d606c55c4d8b to your computer and use it in GitHub Desktop.
Save othiym23/c080e9f5d606c55c4d8b to your computer and use it in GitHub Desktop.
Promises run linearly.
visitAll : function (prefix, target, visitor) {
/* Installs and visits must happen sequentially so node_modules doesn't
* get stomped mid-run.
*/
function installAndVisit(versions, index, result) {
if (!versions[index]) return result;
return installer.visitVersion(prefix, target, versions[index], visitor)
.then(installAndVisit.bind(null, versions, index - 1));
}
function installAll(versions) {
console.log("Installing %s versions of %s.", versions.length, target);
recreate(prefix, 'build-errors');
return installAndVisit(versions, versions.length - 1);
}
return installer.versions(target).then(installAll);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment