Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 6 additions & 27 deletions helpers/copy.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import * as shell from 'shelljs';
import { existsSync } from 'fs';

import * as cpx from 'cpx';

export interface Copy {
from: string;
to: string;
}

/**
* @description apply the copy array using the copy function
* @param arr
* @description apply the copy array using the copy function
* @param arr
*/
export function copyArray(arr: Copy[]) {
for (let copyOp of arr) {
Expand All @@ -19,28 +17,9 @@ export function copyArray(arr: Copy[]) {

/**
* @description function that copy files or folders and take the from path and the toPath
* @param fromPath
* @param toPath
* @param fromPath
* @param toPath
*/
export function copy(fromPath: string, toPath: string) {

// validate file paths
if (!isValidPath(fromPath))
return console.error(`Path "${fromPath}" does not exist`);

if (!isValidPath(toPath))
shell.mkdir('-p', toPath);

shell.cp('-ru', fromPath, toPath);
cpx.copySync(fromPath, toPath);
}

/**
* @description function that validate that file or folder actually exists
* @param path
*/
function isValidPath(path: string, ) {
if (!existsSync(path))
return false;

return true;
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@angular-devkit/architect": "^0.803.13",
"@angular-devkit/core": "^8.3.13",
"concurrently": "^5.0.0",
"cpx": "^1.5.0",
"nodemon": "^1.19.4",
"rimraf": "^3.0.0",
"shelljs": "^0.8.3",
Expand All @@ -34,11 +35,12 @@
},
"devDependencies": {
"@types/concurrently": "^4.1.0",
"@types/cpx": "^1.5.1",
"@types/jasmine": "^3.4.4",
"@types/node": "^12.11.5",
"@types/nodemon": "^1.19.0",
"@types/rimraf": "^2.0.3",
"@types/shelljs": "^0.8.6",
"jasmine": "^3.5.0"
}
}
}
Loading