or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

archive.mdconfiguration.mdcopy.mddelete.mdindex.mdmkdir.mdmove.md
tile.json

copy.mddocs/

Copy Operations

Copy individual files or entire directories with glob pattern support, flexible destination handling, and comprehensive options for preserving metadata and controlling behavior.

Capabilities

Copy Action Function

Main copy action function that processes copy tasks.

/**
 * Execute copy tasks with the provided options
 * @param tasks Array of copy tasks to execute
 * @param taskOptions Execution options including logger and error handling
 */
function copyAction(tasks: CopyTask[], taskOptions: TaskOptions): Promise<void>;

export default copyAction;

Copy Options

Options for controlling copy behavior, file handling, and metadata preservation.

/**
 * Options for copy operations extending fs-extra CopyOptions
 */
interface CopyActionOptions extends FsCopyOptions {
  /** Flatten directory structure - copy all files to destination root (default: false) */
  flat?: boolean;
}

/**
 * fs-extra copy options used by CopyActionOptions
 */
type FsCopyOptions = Pick<CopyOptions, 'overwrite' | 'preserveTimestamps'>;

/**
 * Fast-glob options for copy operations (excludes absolute and cwd)
 */
type CopyGlobOptions = Omit<FgOptions, 'absolute' | 'cwd'>;

Task Options

Options passed to copy task execution functions.

/**
 * Task execution options
 */
type TaskOptions = {
  runTasksInSeries: boolean;
  logger: Logger;
  handleError: (error: Error) => void;
};

Internal Task Structure

Internal task structure used by the plugin during execution.

/**
 * Internal task structure for copy operations
 */
interface CopyTask {
  source: string;
  absoluteSource: string;
  destination: string;
  absoluteDestination?: string;
  context?: string;
  toType?: 'dir' | 'file';
  options?: CopyActionOptions;
  globOptions?: CopyGlobOptions;
}

Usage Examples:

// Basic file copy
{
  copy: [
    { source: './src/config.json', destination: './dist/config.json' }
  ]
}

// Directory copy
{
  copy: [
    { source: './src/assets', destination: './dist/assets' }
  ]
}

// Glob pattern copy
{
  copy: [
    { source: './src/**/*.js', destination: './dist' },
    { source: './src/**/*.{html,css}', destination: './dist' }
  ]
}

// Copy with options
{
  copy: [
    {
      source: './src/images',
      destination: './dist/assets',
      options: {
        flat: true,
        overwrite: false,
        preserveTimestamps: true
      }
    }
  ]
}

// Copy with glob options
{
  copy: [
    {
      source: './src/**/*',
      destination: './dist',
      globOptions: {
        dot: true,        // Include hidden files
        ignore: ['**/*.tmp', '**/*.log']
      }
    }
  ]
}

// Copy file into directory (trailing slash indicates directory)
{
  copy: [
    { source: './README.md', destination: './dist/' }
  ]
}

Copy Behavior Rules

Source and Destination Logic

  • File to File: Direct file copy with optional rename
  • File to Directory: Copy file into directory (destination ends with / or is existing directory)
  • Directory to Directory: Copy entire directory contents
  • Glob to Directory: Copy all matching files/directories to destination

Glob Pattern Support

  • Standard glob patterns: *, **, ?, [...]
  • Brace expansion: {js,ts}, {file1,file2}
  • Negation patterns in globOptions.ignore

Path Resolution

  • Relative paths resolved against plugin context or Webpack context
  • Absolute paths used as-is
  • Destination paths normalized for cross-platform compatibility