11import {
2+ copySync ,
23 createWriteStream ,
34 existsSync ,
45 readdirSync ,
56 readFileSync ,
6- writeFileSync
7- } from 'fs' ;
7+ writeFileSync ,
8+ } from 'fs-extra ' ;
89import * as http from 'http' ;
910import * as https from 'https' ;
1011import * as yaml from 'js-yaml' ;
@@ -24,18 +25,16 @@ const isHttpsRegex = /^https/i;
2425 * @returns The resolved path to the resource
2526 * @throws Exception if path not exist or not found
2627 */
27- export function resolvePluggablePath ( elementPath : string , internalPath : string ) {
28+ export function resolvePluggablePath (
29+ elementPath : string ,
30+ internalPath : string ,
31+ ) {
2832 // Generate the template path
2933 if ( existsSync ( elementPath ) ) {
3034 return elementPath ;
3135 }
3236
33- const resolvedPath = pathResolve (
34- __dirname ,
35- '..' ,
36- internalPath ,
37- elementPath ,
38- ) ;
37+ const resolvedPath = pathResolve ( __dirname , '..' , internalPath , elementPath ) ;
3938 if ( existsSync ( resolvedPath ) ) {
4039 return resolvedPath ;
4140 }
@@ -53,6 +52,24 @@ export function makeDir(dest): void {
5352 mkdirSync ( dest ) ;
5453}
5554
55+
56+ function copyDirFilter ( src , dst ) : boolean {
57+ return dst . indexOf ( 'node_modules' ) === - 1 ;
58+ }
59+
60+ export function copyDir (
61+ src : string ,
62+ dest : string ,
63+ overwrite : boolean = false ,
64+ ) : void {
65+ console . debug ( 'Copying' , src , 'to' , dest ) ;
66+ copySync ( src , dest , {
67+ overwrite : true ,
68+ errorOnExist : true ,
69+ filter : copyDirFilter ,
70+ } ) ;
71+ }
72+
5673export async function downloadFile ( url , dest ) : Promise < string > {
5774 makeDir ( dirname ( dest ) ) ;
5875 return new Promise ( ( resolve , error ) => {
0 commit comments