Home Manual Reference Source
public class | source

Copier

A service to copy items.

Static Method Summary

Static Public Methods
public static

copy(origin: string, target: string, items: Array): Promise<Array, Error>

Copy a list of items between an origin directory and a target directory.

public static

Copy a single file from one location to another.

public static

Copy a Node module.

public static

Given a list of items, find if any of them doesn't exist.

public static

Check if an item exists.

Static Public Methods

public static copy(origin: string, target: string, items: Array): Promise<Array, Error> source

Copy a list of items between an origin directory and a target directory.

Params:

NameTypeAttributeDescription
origin string

The path to the origin directory.

target string

The path to the target directory.

items Array

The list of items to copy. Each item can be a string with the path to the item, or an object with origin path of the file as key and the target path as value.

Return:

Promise<Array, Error>

If everything goes well, the promise will resolve on a list with the information of every item it copied.

public static copyFile(from: string, to: string): Promise<Object, Object> source

Copy a single file from one location to another.

Params:

NameTypeAttributeDescription
from string

The current location of the file.

to string

The location of the copy.

Return:

Promise<Object, Object>

The promise will resolve on an object with the information of the process: from, to and success.

public static copyModule(from: string, to: string): Promise<Object, Object> source

Copy a Node module. The reason this is different from copyFile is because instead of copying the entire module, we first read all the files on its directory, remove its modules and the lock files and then copy all the rest.

Params:

NameTypeAttributeDescription
from string

The module path.

to string

The path to where it will be copied.

Return:

Promise<Object, Object>

The promise will resolve on an object with the information of the process: from, to and success.

public static findMissingItems(items: Array): Promise<Array, Error> source

Given a list of items, find if any of them doesn't exist.

Params:

NameTypeAttributeDescription
items Array

A list of paths.

Return:

Promise<Array, Error>

If everything goes well, the promise will resolve on a list of objects with the path for the item and a flag to indicate if they exists.

public static pathExists(item: string): Promise<Object, Error> source

Check if an item exists.

Params:

NameTypeAttributeDescription
item string

The path for the item.

Return:

Promise<Object, Error>

If everything goes well, the promise will resolve on an object with the keys item, for the item path, and exists to indicate whether the item exists or not.