@@ -18,9 +18,8 @@ export class Builder implements IBroccoliBuilder {
18
18
private $projectData : IProjectData ,
19
19
private $projectDataService : IProjectDataService ,
20
20
private $injector : IInjector ,
21
- private $logger : ILogger
22
- ) {
23
- }
21
+ private $logger : ILogger ,
22
+ private $lockfile : ILockFile ) { }
24
23
25
24
public getChangedNodeModules ( absoluteOutputPath : string , platform : string , lastModifiedTime ?: Date ) : IFuture < any > {
26
25
return ( ( ) => {
@@ -38,10 +37,13 @@ export class Builder implements IBroccoliBuilder {
38
37
stat : true
39
38
} , ( er : Error , files : string [ ] ) => {
40
39
fiberBootstrap . run ( ( ) => {
40
+ this . $lockfile . lock ( ) . wait ( ) ;
41
41
if ( er ) {
42
42
if ( ! future . isResolved ( ) ) {
43
43
future . throw ( er ) ;
44
44
}
45
+
46
+ this . $lockfile . unlock ( ) . wait ( ) ;
45
47
match . abort ( ) ;
46
48
return ;
47
49
}
@@ -59,6 +61,7 @@ export class Builder implements IBroccoliBuilder {
59
61
}
60
62
if ( file === constants . NODE_MODULES_FOLDER_NAME ) {
61
63
isNodeModulesModified = true ;
64
+ this . $lockfile . unlock ( ) . wait ( ) ;
62
65
match . abort ( ) ;
63
66
if ( ! future . isResolved ( ) ) {
64
67
future . return ( ) ;
@@ -69,29 +72,38 @@ export class Builder implements IBroccoliBuilder {
69
72
let rootModuleFullPath = path . join ( nodeModulesPath , rootModuleName ) ;
70
73
nodeModules [ rootModuleFullPath ] = rootModuleFullPath ;
71
74
}
75
+
76
+ this . $lockfile . unlock ( ) . wait ( ) ;
72
77
} ) ;
73
78
} ) ;
74
79
match . on ( "end" , ( ) => {
75
80
if ( ! future . isResolved ( ) ) {
76
- future . return ( ) ;
81
+ let intervalId = setInterval ( ( ) => {
82
+ fiberBootstrap . run ( ( ) => {
83
+ if ( ! this . $lockfile . check ( ) . wait ( ) ) {
84
+ future . return ( ) ;
85
+ clearInterval ( intervalId ) ;
86
+ }
87
+ } ) ;
88
+ } , 100 ) ;
77
89
}
78
90
} ) ;
79
91
80
92
future . wait ( ) ;
81
93
}
82
94
83
- if ( isNodeModulesModified && this . $fs . exists ( absoluteOutputPath ) . wait ( ) ) {
95
+ if ( isNodeModulesModified && this . $fs . exists ( absoluteOutputPath ) . wait ( ) ) {
84
96
let currentPreparedTnsModules = this . $fs . readDirectory ( absoluteOutputPath ) . wait ( ) ;
85
97
let tnsModulesPath = path . join ( projectDir , constants . APP_FOLDER_NAME , constants . TNS_MODULES_FOLDER_NAME ) ;
86
- if ( ! this . $fs . exists ( tnsModulesPath ) . wait ( ) ) {
98
+ if ( ! this . $fs . exists ( tnsModulesPath ) . wait ( ) ) {
87
99
tnsModulesPath = path . join ( projectDir , constants . NODE_MODULES_FOLDER_NAME , constants . TNS_CORE_MODULES_NAME ) ;
88
100
}
89
101
let tnsModulesInApp = this . $fs . readDirectory ( tnsModulesPath ) . wait ( ) ;
90
102
let modulesToDelete = _ . difference ( currentPreparedTnsModules , tnsModulesInApp ) ;
91
103
_ . each ( modulesToDelete , moduleName => this . $fs . deleteDirectory ( path . join ( absoluteOutputPath , moduleName ) ) . wait ( ) ) ;
92
104
}
93
105
94
- if ( ! lastModifiedTime || isNodeModulesModified ) {
106
+ if ( ! lastModifiedTime || isNodeModulesModified ) {
95
107
this . listModules ( nodeModulesPath , nodeModules ) ;
96
108
}
97
109
0 commit comments