UNPKG

@dscodotco/theme-cli

Version:

A CLI tool for developing Shopify themes

41 lines (40 loc) 1.28 kB
/** * @module utils/download * @description Utilities for downloading files from URLs */ import { ResponseType } from "../types/index.js"; /** * Downloads a file from a URL * * @param url - The URL to download from * @param responseType - The axios response type * @returns The response data, type varies based on responseType * * @example * ```typescript * // Download a file as an arraybuffer * const data = await downloadFile('https://example.com/file.zip'); * * // Download a file as JSON * const jsonData = await downloadFile('https://api.example.com/data', 'json'); * ``` * * @throws Will throw an error if the download fails */ export declare function downloadFile(url: string, responseType?: ResponseType): Promise<any>; /** * Downloads a file from a URL and saves it to disk * * @param url - The URL to download from * @param outputPath - The path to save the file to * @returns A promise that resolves when the file is saved * * @example * ```typescript * // Download and save a file * await downloadAndSaveFile('https://example.com/file.zip', './downloads/file.zip'); * ``` * * @throws Will throw an error if the download or save fails */ export declare function downloadAndSaveFile(url: string, outputPath: string): Promise<void>;