Skip to content

[Performance] Memoize isWsl#7739

Draft
gonzaloriestra wants to merge 1 commit into
mainfrom
performance-memoize-iswsl-3156475889461505530
Draft

[Performance] Memoize isWsl#7739
gonzaloriestra wants to merge 1 commit into
mainfrom
performance-memoize-iswsl-3156475889461505530

Conversation

@gonzaloriestra
Copy link
Copy Markdown
Contributor

Why is this change necessary?

The `isWsl` function performs a dynamic import and checks environment variables/filesystem to determine if the environment is WSL. This check is performed frequently, particularly during analytics generation.

Performance Impact

Memoizing the result avoids redundant dynamic imports and system probes after the first call, reducing CPU and I/O overhead in high-frequency execution paths.

How to test your changes?

CI


PR created automatically by Jules for task 3156475889461505530 started by @gonzaloriestra

Memoize the \`isWsl\` function in \`packages/cli-kit/src/public/node/system.ts\` to avoid redundant dynamic imports and filesystem/environment checks. This function is checked frequently during analytics generation.

Performance Impact:
Reduced dynamic imports and system probes after the first call.

How to test your changes:
CI
@google-labs-jules
Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions github-actions Bot added the no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. label Jun 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 7, 2026

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/public/node/system.d.ts
 import { AbortSignal } from './abort.js';
 import type { Writable, Readable } from 'stream';
 export interface ExecOptions {
     cwd?: string;
     env?: Record<string, string | undefined>;
     stdin?: Readable | 'inherit';
     stdout?: Writable | 'inherit';
     stderr?: Writable | 'inherit';
     stdio?: 'inherit';
     input?: string;
     signal?: AbortSignal;
     externalErrorHandler?: (error: unknown) => Promise<void>;
     background?: boolean;
 }
 /**
  * Opens a URL in the user's default browser.
  *
  * @param url - URL to open.
  * @returns A promise that resolves true if the URL was opened successfully, false otherwise.
  */
 export declare function openURL(url: string): Promise<boolean>;
 /**
  * Runs a command asynchronously, aggregates the stdout data, and returns it.
  *
  * @param command - Command to be executed.
  * @param args - Arguments to pass to the command.
  * @param options - Optional settings for how to run the command.
  * @returns A promise that resolves with the aggregatted stdout of the command.
  */
 export declare function captureOutput(command: string, args: string[], options?: ExecOptions): Promise<string>;
 /**
  * Result from running a command with captureOutputWithExitCode.
  */
 export interface CaptureOutputResult {
     /** Standard output. */
     stdout: string;
     /** Standard error. */
     stderr: string;
     /** Exit code (0 = success). */
     exitCode: number;
 }
 /**
  * Runs a command asynchronously and returns stdout, stderr, and exit code.
  * Unlike captureOutput, this function does NOT throw on non-zero exit codes.
  *
  * @param command - Command to be executed.
  * @param args - Arguments to pass to the command.
  * @param options - Optional settings for how to run the command.
  * @returns A promise that resolves with stdout, stderr, and exitCode.
  *
  * @example
  * ```typescript
  * const result = await captureOutputWithExitCode('ls', ['-la'])
- * if (result.exitCode !== 0) \{
+ * if (result.exitCode !== 0) {
  *   console.error('Command failed:', result.stderr)
- * \}
+ * }
  * ```
  */
 export declare function captureOutputWithExitCode(command: string, args: string[], options?: ExecOptions): Promise<CaptureOutputResult>;
 /**
  * Runs a command string asynchronously and returns stdout, stderr, and exit code.
  * Parses the command string into command and arguments (handles quoted strings).
  * Unlike captureOutput, this function does NOT throw on non-zero exit codes.
  *
  * @param command - Full command string to be executed (e.g., 'ls -la "my folder"').
  * @param options - Optional settings for how to run the command.
  * @returns A promise that resolves with stdout, stderr, and exitCode.
  *
  * @example
  * ```typescript
  * const result = await captureCommandWithExitCode('shopify theme push --theme "My Theme"')
  * if (result.exitCode !== 0) {
  *   console.error('Command failed:', result.stderr)
  * }
  * ```
  */
 export declare function captureCommandWithExitCode(command: string, options?: ExecOptions): Promise<CaptureOutputResult>;
 /**
  * Runs a command string asynchronously (parses command and arguments from the string).
  *
  * @param command - Full command string to be executed (e.g., 'ls -la "my folder"').
  * @param options - Optional settings for how to run the command.
  */
 export declare function execCommand(command: string, options?: ExecOptions): Promise<void>;
 /**
  * Runs a command asynchronously.
  *
  * @param command - Command to be executed.
  * @param args - Arguments to pass to the command.
  * @param options - Optional settings for how to run the command.
  */
 export declare function exec(command: string, args: string[], options?: ExecOptions): Promise<void>;
 /**
  * Waits for a given number of seconds.
  *
  * @param seconds - Number of seconds to wait.
  * @returns A Promise resolving after the number of seconds.
  */
 export declare function sleep(seconds: number): Promise<void>;
 /**
  * Check if the terminal supports OSC 8 hyperlinks.
  *
  * @returns True if the terminal supports hyperlinks.
  */
 export declare function terminalSupportsHyperlinks(): boolean;
 /**
  * Check if the standard input and output streams support prompting.
  *
  * @returns True if the standard input and output streams support prompting.
  */
 export declare function terminalSupportsPrompting(): boolean;
 /**
  * Check if the current environment is a CI environment.
  *
  * @returns True if the current environment is a CI environment.
  */
 export declare function isCI(): boolean;
 /**
  * Check if the current environment is a WSL environment.
  *
  * @returns True if the current environment is a WSL environment.
  */
 export declare function isWsl(): Promise<boolean>;
 /**
  * Check if stdin has piped data available.
  * This distinguishes between actual piped input (e.g., `echo "query" | cmd`)
  * and non-TTY environments without input (e.g., CI).
  *
  * @returns True if stdin is receiving piped data or file redirect, false otherwise.
  */
 export declare function isStdinPiped(): boolean;
 /**
  * Reads all data from stdin and returns it as a string.
  * This is useful for commands that accept input via piping.
  *
  * @example
  * // Usage: echo "your query" | shopify app execute
  * const query = await readStdin()
  *
  * @returns A promise that resolves with the stdin content, or undefined if stdin is a TTY.
  */
 export declare function readStdinString(): Promise<string | undefined>;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant