@@ -134,23 +134,30 @@ function buildHar() {
134134 }
135135
136136 if ( ! skipInstall ) {
137- runCommand ( ohpmPath , [ 'install' ] , {
138- cwd : harmonyModuleDir ,
139- env,
140- label : 'Install Harmony dependencies' ,
141- } ) ;
137+ if ( hasDependencies ( harmonyModuleDir ) ) {
138+ runCommand ( ohpmPath , [ 'install' ] , {
139+ cwd : harmonyModuleDir ,
140+ env,
141+ label : 'Install Harmony dependencies' ,
142+ } ) ;
143+ }
142144
143- runCommand ( ohpmPath , [ 'install' ] , {
144- cwd : wrapperProjectDir ,
145- env,
146- label : 'Install wrapper project dependencies' ,
147- } ) ;
145+ if ( hasDependencies ( wrapperProjectDir ) ) {
146+ runCommand ( ohpmPath , [ 'install' ] , {
147+ cwd : wrapperProjectDir ,
148+ env,
149+ label : 'Install wrapper project dependencies' ,
150+ } ) ;
151+ }
148152 }
149153
150154 const hvigorArgs = [ 'assembleHar' ] ;
151155 if ( buildMode !== 'debug' ) {
152156 hvigorArgs . push ( '-p' , `buildMode=${ buildMode } ` ) ;
153157 }
158+ if ( process . env . CI === 'true' ) {
159+ hvigorArgs . push ( '--no-daemon' ) ;
160+ }
154161
155162 runCommand ( hvigorwPath , hvigorArgs , {
156163 cwd : wrapperProjectDir ,
@@ -437,3 +444,20 @@ function relativeToProject(filePath) {
437444function fail ( message ) {
438445 throw new Error ( message ) ;
439446}
447+
448+ function hasDependencies ( dir ) {
449+ try {
450+ const pkgPath = path . join ( dir , 'oh-package.json5' ) ;
451+ if ( ! fs . existsSync ( pkgPath ) ) {
452+ return false ;
453+ }
454+ const pkgContent = fs . readFileSync ( pkgPath , 'utf8' ) ;
455+ const cleanJson = pkgContent . replace ( / \/ \* [ \s \S ] * ?\* \/ | ( [ ^ \\ : ] | ^ ) \/ \/ .* $ / gm, '' ) ;
456+ const pkg = eval ( '(' + cleanJson + ')' ) ;
457+ const hasDeps = pkg . dependencies && Object . keys ( pkg . dependencies ) . length > 0 ;
458+ const hasDevDeps = pkg . devDependencies && Object . keys ( pkg . devDependencies ) . length > 0 ;
459+ return ! ! ( hasDeps || hasDevDeps ) ;
460+ } catch ( e ) {
461+ return true ;
462+ }
463+ }
0 commit comments