@@ -38,7 +38,8 @@ function archive_project(lt_config) {
3838
3939 archive . on ( "error" , function ( err ) {
4040 console . log ( "ERROR" , err ) ;
41- throw err ;
41+ reject ( err ) ;
42+ //throw err;
4243 } ) ;
4344
4445 // pipe archive data to the file
@@ -68,7 +69,7 @@ function archive_project(lt_config) {
6869 console . log ( "Ignoring files: " , ignore_files ) ;
6970 archive . glob (
7071 "**/*" ,
71- { cwd : process . cwd ( ) , ignore : ignore_files } ,
72+ { cwd : process . cwd ( ) , ignore : ignore_files , dot : true } ,
7273 { prefix : "project/" }
7374 ) ;
7475 //OverRide NPM Dependencies
@@ -88,6 +89,44 @@ function archive_project(lt_config) {
8889 } ,
8990 { prefix : "project/" }
9091 ) ;
92+ if (
93+ lt_config . run_settings . dep_tokens &&
94+ lt_config . run_settings . dep_tokens . length > 0
95+ ) {
96+ if ( fs . existsSync ( ".npmrc" ) ) {
97+ let raw_data = fs . readFileSync ( ".npmrc" , "utf8" ) ;
98+ let replace_map = { } ;
99+ for ( let i = 0 ; i < lt_config . run_settings . dep_tokens . length ; i ++ ) {
100+ if ( process . env [ lt_config . run_settings . dep_tokens [ i ] ] ) {
101+ //Used for creating regular expression by escaping the $ and {}
102+ replace_map [
103+ "\\$\\{" + lt_config . run_settings . dep_tokens [ i ] + "\\}"
104+ ] = process . env [ lt_config . run_settings . dep_tokens [ i ] ] ;
105+ //User for String replacement
106+ replace_map [ "${" + lt_config . run_settings . dep_tokens [ i ] + "}" ] =
107+ process . env [ lt_config . run_settings . dep_tokens [ i ] ] ;
108+ } else {
109+ reject ( "Dep Tokens are not in environment" ) ;
110+ return ;
111+ }
112+ }
113+ var re = new RegExp ( Object . keys ( replace_map ) . join ( "|" ) , "gi" ) ;
114+ raw_data = raw_data . replace ( re , function ( matched ) {
115+ return replace_map [ matched ] ;
116+ } ) ;
117+ archive . append (
118+ raw_data ,
119+ {
120+ name : "project/.npmrc" ,
121+ cwd : process . cwd ( ) ,
122+ ignore : ignore_files ,
123+ } ,
124+ { prefix : "project/" }
125+ ) ;
126+ } else {
127+ reject ( "Dep Tokens are passed but .npmrc does not exist" ) ;
128+ }
129+
91130 }
92131
93132 archive . finalize ( ) ;
0 commit comments