9
9
{ get_version } = require ( './usageReporting' ) ,
10
10
process = require ( 'process' ) ,
11
11
{ spawn } = require ( 'child_process' ) ,
12
+ cliUtils = require ( "./utils" ) ,
12
13
util = require ( 'util' ) ;
13
14
14
15
let nodeProcess ;
@@ -58,7 +59,7 @@ const setupPackageFolder = (runSettings, directoryPath) => {
58
59
} )
59
60
} ;
60
61
61
- const packageInstall = ( packageDir ) => {
62
+ const packageInstall = ( packageDir , bsConfig ) => {
62
63
return new Promise ( function ( resolve , reject ) {
63
64
const nodeProcessCloseCallback = ( code ) => {
64
65
if ( code == 0 ) {
@@ -74,6 +75,16 @@ const packageInstall = (packageDir) => {
74
75
reject ( `Packages were not installed successfully. Error Description ${ util . format ( '%j' , error ) } ` ) ;
75
76
} ;
76
77
78
+ // Moving .npmrc to tmpBstackPackages
79
+ try {
80
+ logger . debug ( `Copying .npmrc file to temporary package directory` ) ;
81
+ const npmrcRootPath = path . join ( cliUtils . isNotUndefined ( bsConfig . run_settings . home_directory ) ? path . resolve ( bsConfig . run_settings . home_directory ) : './' , '.npmrc' ) ;
82
+ const npmrcTmpPath = path . join ( path . resolve ( packageDir ) , '.npmrc' ) ;
83
+ fs . copyFileSync ( npmrcRootPath , npmrcTmpPath ) ;
84
+ } catch ( error ) {
85
+ logger . debug ( `Failed copying .npmrc to ${ packageDir } : ${ error } ` )
86
+ }
87
+
77
88
let nodeProcess ;
78
89
logger . debug ( `Fetching npm version and its major version` ) ;
79
90
const npm_version = get_version ( 'npm' )
@@ -147,7 +158,7 @@ const packageSetupAndInstaller = (bsConfig, packageDir, instrumentBlocks) => {
147
158
instrumentBlocks . markBlockEnd ( "packageInstaller.folderSetup" ) ;
148
159
instrumentBlocks . markBlockStart ( "packageInstaller.packageInstall" ) ;
149
160
logger . debug ( "Started installing dependencies specified in browserstack.json" ) ;
150
- return packageInstall ( packageDir ) ;
161
+ return packageInstall ( packageDir , bsConfig ) ;
151
162
} ) . then ( ( _result ) => {
152
163
logger . debug ( "Completed installing dependencies" ) ;
153
164
instrumentBlocks . markBlockEnd ( "packageInstaller.packageInstall" ) ;
0 commit comments