Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 66ACB11BD1 for ; Fri, 6 Jun 2014 14:55:39 +0000 (UTC) Received: (qmail 13115 invoked by uid 500); 6 Jun 2014 14:55:39 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 13014 invoked by uid 500); 6 Jun 2014 14:55:39 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 13004 invoked by uid 99); 6 Jun 2014 14:55:39 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Jun 2014 14:55:39 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id CE0988BA172; Fri, 6 Jun 2014 14:55:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: agrieve@apache.org To: commits@cordova.apache.org Date: Fri, 06 Jun 2014 14:55:39 -0000 Message-Id: <3927d7ce860c458d84cfe5e67661b863@git.apache.org> In-Reply-To: <9df323fcb9684123851f470179ccbba4@git.apache.org> References: <9df323fcb9684123851f470179ccbba4@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] git commit: Don't require commands that aren't being run (speeds up gnode version) Don't require commands that aren't being run (speeds up gnode version) Project: http://git-wip-us.apache.org/repos/asf/cordova-coho/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-coho/commit/181b2fa1 Tree: http://git-wip-us.apache.org/repos/asf/cordova-coho/tree/181b2fa1 Diff: http://git-wip-us.apache.org/repos/asf/cordova-coho/diff/181b2fa1 Branch: refs/heads/master Commit: 181b2fa13a5069b98f343eaa5a79eef9d4ed9061 Parents: 20934b2 Author: Andrew Grieve Authored: Fri Jun 6 10:55:00 2014 -0400 Committer: Andrew Grieve Committed: Fri Jun 6 10:55:00 2014 -0400 ---------------------------------------------------------------------- src/main.js | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/181b2fa1/src/main.js ---------------------------------------------------------------------- diff --git a/src/main.js b/src/main.js index 9025e75..90229ed 100644 --- a/src/main.js +++ b/src/main.js @@ -29,82 +29,90 @@ try { } var apputil = require('./apputil'); +function *lazyRequire(name, opt_prop) { + if (opt_prop) { + yield require(name)[opt_prop]; + } else { + yield require(name); + } +} + module.exports = function() { var repoCommands = [ { name: 'repo-clone', desc: 'Clones git repositories into the current working directory.', - entryPoint: require('./repo-clone') + entryPoint: lazyRequire('./repo-clone') }, { name: 'repo-update', desc: 'Performs git pull --rebase on all specified repositories.', - entryPoint: require('./repo-update') + entryPoint: lazyRequire('./repo-update') }, { name: 'repo-reset', desc: 'Performs git reset --hard origin/$BRANCH and git clean -f -d on all specified repositories.', - entryPoint: require('./repo-reset') + entryPoint: lazyRequire('./repo-reset') }, { name: 'repo-status', desc: 'Lists changes that exist locally but have not yet been pushed.', - entryPoint: require('./repo-status') + entryPoint: lazyRequire('./repo-status') }, { name: 'repo-push', desc: 'Push changes that exist locally but have not yet been pushed.', - entryPoint: require('./repo-push') + entryPoint: lazyRequire('./repo-push') }, { name: 'list-repos', desc: 'Shows a list of valid values for the --repo flag.', - entryPoint: require('./list-repos') + entryPoint: lazyRequire('./list-repos') }]; var releaseCommands = [{ name: 'prepare-release-branch', desc: 'Branches, updates JS, updates VERSION. Safe to run multiple times.', - entryPoint: require('./cadance-release').prepareReleaseBranchCommand + entryPoint: lazyRequire('./cadance-release', 'prepareReleaseBranchCommand') }, { name: 'tag-release', desc: 'Tags repos for a release.', - entryPoint: require('./cadance-release').tagReleaseBranchCommand + entryPoint: lazyRequire('./cadance-release', 'tagReleaseBranchCommand') }, { name: 'audit-license-headers', desc: 'Uses Apache RAT to look for missing license headers.', - entryPoint: require('./audit-license-headers') + entryPoint: lazyRequire('./audit-license-headers') }, { name: 'create-release-bug', desc: 'Creates a bug in JIRA for tracking the tasks involved in a new release', - entryPoint: require('./create-release-bug') + entryPoint: lazyRequire('./create-release-bug') }, { name: 'create-archive', desc: 'Zips up a tag, signs it, and adds checksum files.', - entryPoint: require('./create-verify-archive').createCommand + entryPoint: lazyRequire('./create-verify-archive', 'createCommand') }, { name: 'verify-archive', desc: 'Checks that archives are properly signed and hashed.', - entryPoint: require('./create-verify-archive').verifyCommand + entryPoint: lazyRequire('./create-verify-archive', 'verifyCommand') }, { name: 'print-tags', desc: 'Prints out tags & hashes for the given repos. Used in VOTE emails.', - entryPoint: require('./print-tags') + entryPoint: lazyRequire('./print-tags') }, { name: 'list-release-urls', desc: 'List the apache git repo urls for release artifacts.', - entryPoint: require('./list-release-urls') + entryPoint: lazyRequire('./list-release-urls') }]; var otherCommands = [{ name: 'list-pulls', desc: 'Shows a list of GitHub pull requests for all specified repositories.', - entryPoint: require('./list-pulls') + entryPoint: lazyRequire('./list-pulls') }, { name: 'last-week', desc: 'Prints out git logs of things that happened last week.', - entryPoint: require('./last-week') + entryPoint: lazyRequire('./last-week') }, { name: 'shortlog', desc: 'A version of `git shortlog -s` aggregated across multiple repos.', - entryPoint: require('./shortlog') + entryPoint: lazyRequire('./shortlog') }, { name: 'for-each', desc: 'Runs a shell command in each repo.', - entryPoint: require('./for-each') + entryPoint: lazyRequire('./for-each') } ]; var commandMap = {};