[Performance] Memoize isShopify environment check#7606
Conversation
Memoize the result promise of isShopify when using the default process.env. This avoids redundant filesystem checks for the /opt/dev/bin/dev executable, which is particularly beneficial in hot paths like analytics reporting. The cache is bypassed during unit tests to maintain isolation.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Description
This PR implements memoization for the
isShopifyfunction in@shopify/cli-kit. This function determines if the CLI is running in a Shopify internal development environment by checking environment variables and performing a file existence check for the/opt/dev/bin/devexecutable.Since
isShopifyis called multiple times during a CLI command's lifecycle (e.g., in analytics reporting), caching the result promise prevents redundant disk I/O. The memoization is restricted to calls using the defaultprocess.envand is bypassed during unit tests to ensure test isolation.How to test your changes?
CI
Checklist
PR created automatically by Jules for task 1733951532173800447 started by @gonzaloriestra