Home Reference Source Test
import Linker from 'shinka-cli/src/Linker/Linker.js'
public class | source

Linker

Handles creating and destroying symlinks.

Test:

Constructor Summary

Public Constructor
public

constructor(cmd: Cmd, config: Config, logger: LogObject)

Member Summary

Public Members
public

bar: ProgressBar

Progress bar.

public

cmd: Cmd

Command arguments.

public

Config to pull linkables from.

public

Current working directory, used to build absolute paths.

public

destroyLink(path: string): *

Destroys symlink and outputs progress.

public

Paths and associated errors.

public

logger#log is used to output progress, e.g.

public

makeLink(path: string, type: string): *

Creates symlink and outputs progress.

public

Length of longest path.

public

Number of files and directories.

public

Verbs to use in composing messages.

Method Summary

Public Methods
public

errors(): string[]

Builds error messages.

public

Calculates length of longest file or directory name.

public

link(config: Config): Linker

Links items and outputs progress.

public

Outputs error messages.

public

outputProgress(path: string, error: Error)

Outputs status message and updates progress bar.

public

Outputs success message.

public

progress(path: string, error: Error): string

Builds progress message in format `(Un)Linking...

public

Builds success message.

public

unlink(config: Config): Linker

Unlinks items and outputs progress.

Public Constructors

public constructor(cmd: Cmd, config: Config, logger: LogObject) source

Params:

NameTypeAttributeDescription
cmd Cmd
config Config
  • optional
  • default: this.config
logger LogObject
  • optional
  • default: new Logger()

Test:

Public Members

public bar: ProgressBar source

Progress bar.

public cmd: Cmd source

Command arguments.

public config: Config source

Config to pull linkables from.

public cwd: string source

Current working directory, used to build absolute paths.

Destroys symlink and outputs progress.

Test:

public errorList: LinkError[] source

Paths and associated errors.

public logger: LogObject source

logger#log is used to output progress, e.g. Logger#log or console#log.

Creates symlink and outputs progress.

Test:

public maxLength: number source

Length of longest path.

public total: number source

Number of files and directories.

public verbs: Verbs source

Verbs to use in composing messages.

Public Methods

public errors(): string[] source

Builds error messages.

Return:

string[]

Test:

public getMaxLength(): number source

Calculates length of longest file or directory name.

Return:

number

Links items and outputs progress.

Params:

NameTypeAttributeDescription
config Config

Return:

Linker

Return Properties:

NameTypeAttributeDescription
config.files string[]
config.directories string[]

Test:

public outputErrors() source

Outputs error messages.

public outputProgress(path: string, error: Error) source

Outputs status message and updates progress bar.

Params:

NameTypeAttributeDescription
path string
error Error
  • optional
  • nullable: true

public outputSuccess() source

Outputs success message.

public progress(path: string, error: Error): string source

Builds progress message in format (Un)Linking... to/a/path Status

Params:

NameTypeAttributeDescription
path string
error Error
  • optional
  • nullable: true

Return:

string

Test:

public success(): string source

Builds success message.

Return:

string

Test:

Unlinks items and outputs progress.

Params:

NameTypeAttributeDescription
config Config

Return:

Linker

Return Properties:

NameTypeAttributeDescription
config.files string[]
config.directories string[]

Test: