Represents a theme on the file system.

interface ThemeFileSystem {
    addEventListener: (<T>(eventName, cb) => void);
    applyIgnoreFilters: (<T>(files) => T[]);
    delete: ((fileKey) => Promise<void>);
    files: Map<string, ThemeAsset>;
    read: ((fileKey) => Promise<undefined | string | Buffer>);
    ready: (() => Promise<void>);
    root: string;
    startWatcher: ((themeId, adminSession) => Promise<void>);
    unsyncedFileKeys: Set<string>;
    write: ((asset) => Promise<void>);
}

Hierarchy (view full)

Properties

addEventListener: (<T>(eventName, cb) => void)

Add callbacks to run after certain events are fired.

Type declaration

applyIgnoreFilters: (<T>(files) => T[])

Applies filters to ignore files from .shopifyignore file, --ignore and --only flags.

Type declaration

    • <T>(files): T[]
    • Type Parameters

      • T extends {
            key: string;
        }

      Parameters

      • files: T[]

      Returns T[]

delete: ((fileKey) => Promise<void>)

Removes a file from the local disk and updates the file system

Type declaration

    • (fileKey): Promise<void>
    • Parameters

      • fileKey: string

        The key of the file to remove

      Returns Promise<void>

files: Map<string, ThemeAsset>

Local files.

read: ((fileKey) => Promise<undefined | string | Buffer>)

Reads a file from the local disk and updates the file system Returns a ThemeAsset representing the file that was read Returns undefined if the file does not exist

Type declaration

    • (fileKey): Promise<undefined | string | Buffer>
    • Parameters

      • fileKey: string

        The key of the file to read

      Returns Promise<undefined | string | Buffer>

ready: (() => Promise<void>)

Promise that resolves when all the initial files are found.

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

root: string

The root path of the theme.

startWatcher: ((themeId, adminSession) => Promise<void>)

Starts a file watcher for the theme directory.

Type declaration

    • (themeId, adminSession): Promise<void>
    • Parameters

      • themeId: string

        The ID of the theme being watched.

      • adminSession: AdminSession

        The admin session for API communication.

      Returns Promise<void>

Returns

A Promise that resolves to an FSWatcher instance.

unsyncedFileKeys: Set<string>

File keys that have been modified in memory and are not uploaded yet.

write: ((asset) => Promise<void>)

Writes a file to the local disk and updates the file system

Type declaration

    • (asset): Promise<void>
    • Parameters

      • asset: ThemeAsset

        The ThemeAsset representing the file to write

      Returns Promise<void>