@@ -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,9 +69,52 @@ 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 ) ;
75+ if (
76+ lt_config [ "run_settings" ] [ "dep_tokens" ] &&
77+ lt_config [ "run_settings" ] [ "dep_tokens" ] . length > 0
78+ ) {
79+ if ( fs . existsSync ( ".npmrc" ) ) {
80+ let raw_data = fs . readFileSync ( ".npmrc" , "utf8" ) ;
81+ let replace_map = { } ;
82+ for (
83+ let i = 0 ;
84+ i < lt_config [ "run_settings" ] [ "dep_tokens" ] . length ;
85+ i ++
86+ ) {
87+ if ( process . env [ lt_config [ "run_settings" ] [ "dep_tokens" ] [ i ] ] ) {
88+ //Used for creating regular expression by escaping the $ and {}
89+ replace_map [
90+ "\\$\\{" + lt_config [ "run_settings" ] [ "dep_tokens" ] [ i ] + "\\}"
91+ ] = process . env [ lt_config [ "run_settings" ] [ "dep_tokens" ] [ i ] ] ;
92+ //User for String replacement
93+ replace_map [
94+ "${" + lt_config [ "run_settings" ] [ "dep_tokens" ] [ i ] + "}"
95+ ] = process . env [ lt_config [ "run_settings" ] [ "dep_tokens" ] [ i ] ] ;
96+ } else {
97+ reject ( "Dep Tokens are not in environment" ) ;
98+ return ;
99+ }
100+ }
101+ var re = new RegExp ( Object . keys ( replace_map ) . join ( "|" ) , "gi" ) ;
102+ raw_data = raw_data . replace ( re , function ( matched ) {
103+ return replace_map [ matched ] ;
104+ } ) ;
105+ archive . append (
106+ raw_data ,
107+ {
108+ name : "project/.npmrc" ,
109+ cwd : process . cwd ( ) ,
110+ ignore : ignore_files ,
111+ } ,
112+ { prefix : "project/" }
113+ ) ;
114+ } else {
115+ reject ( "Dep Tokens are passed but .npmrc does not exist" ) ;
116+ }
117+ }
74118
75119 archive . finalize ( ) ;
76120 } ) ;
0 commit comments