File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ module.exports.handler = async function handler(argv) {
2323 let blueprintOptions = argv . _ . slice ( 0 ) ;
2424
2525 try {
26- let message = await emberCliUpdate ( {
26+ let result = await emberCliUpdate ( {
2727 blueprint,
2828 blueprintOptions,
2929 from,
@@ -36,12 +36,27 @@ module.exports.handler = async function handler(argv) {
3636 compareOnly,
3737 statsOnly,
3838 listCodemods,
39- createCustomDiff,
40- wasRunAsExecutable : true
39+ createCustomDiff
4140 } ) ;
41+
42+ let ps = result . resolveConflictsProcess ;
43+ if ( ps ) {
44+ process . stdin . pipe ( ps . stdin ) ;
45+ ps . stdout . pipe ( process . stdout ) ;
46+ ps . stderr . pipe ( process . stderr ) ;
47+ }
48+
49+ let message = await result . promise ;
4250 if ( message ) {
4351 console . log ( message ) ;
4452 }
53+
54+ // since we are piping, not inheriting, the child process
55+ // doesn't have the power to close its parent
56+ if ( ps ) {
57+ // eslint-disable-next-line no-process-exit
58+ process . exit ( ) ;
59+ }
4560 } catch ( err ) {
4661 console . error ( err ) ;
4762 }
Original file line number Diff line number Diff line change @@ -22,17 +22,32 @@ module.exports.handler = async function handler(argv) {
2222 let blueprintOptions = argv . _ . slice ( 1 ) ;
2323
2424 try {
25- let message = await init ( {
25+ let result = await init ( {
2626 blueprint,
2727 to,
2828 resolveConflicts,
2929 reset,
30- blueprintOptions,
31- wasRunAsExecutable : true
30+ blueprintOptions
3231 } ) ;
32+
33+ let ps = result . resolveConflictsProcess ;
34+ if ( ps ) {
35+ process . stdin . pipe ( ps . stdin ) ;
36+ ps . stdout . pipe ( process . stdout ) ;
37+ ps . stderr . pipe ( process . stderr ) ;
38+ }
39+
40+ let message = await result . promise ;
3341 if ( message ) {
3442 console . log ( message ) ;
3543 }
44+
45+ // since we are piping, not inheriting, the child process
46+ // doesn't have the power to close its parent
47+ if ( ps ) {
48+ // eslint-disable-next-line no-process-exit
49+ process . exit ( ) ;
50+ }
3651 } catch ( err ) {
3752 console . error ( err ) ;
3853 }
Original file line number Diff line number Diff line change @@ -83,7 +83,15 @@ module.exports = {
8383 ] ,
8484
8585 async run ( options ) {
86- options . wasRunAsExecutable = true ;
87- await emberCliUpdate ( options ) ;
86+ let result = await emberCliUpdate ( options ) ;
87+
88+ let ps = result . resolveConflictsProcess ;
89+ if ( ps ) {
90+ process . stdin . pipe ( ps . stdin ) ;
91+ ps . stdout . pipe ( process . stdout ) ;
92+ ps . stderr . pipe ( process . stderr ) ;
93+ }
94+
95+ await result . promise ;
8896 }
8997} ;
Original file line number Diff line number Diff line change @@ -63,8 +63,7 @@ module.exports = async function emberCliUpdate({
6363 compareOnly,
6464 statsOnly,
6565 listCodemods,
66- createCustomDiff,
67- wasRunAsExecutable
66+ createCustomDiff
6867} ) {
6968 let cwd = process . cwd ( ) ;
7069
@@ -170,7 +169,10 @@ module.exports = async function emberCliUpdate({
170169
171170 let endBlueprint ;
172171
173- let result = await ( await boilerplateUpdate ( {
172+ let {
173+ promise,
174+ resolveConflictsProcess
175+ } = await boilerplateUpdate ( {
174176 projectOptions : ( { packageJson } ) => getProjectOptions ( packageJson , blueprint ) ,
175177 mergeOptions : async function mergeOptions ( {
176178 packageJson,
@@ -250,23 +252,29 @@ module.exports = async function emberCliUpdate({
250252 codemodsUrl,
251253 codemodsJson,
252254 createCustomDiff,
253- ignoredFiles : [ await getBlueprintRelativeFilePath ( cwd ) ] ,
254- wasRunAsExecutable
255- } ) ) . promise ;
256-
257- if ( _blueprint || isPersistedBlueprint ) {
258- await saveBlueprint ( {
259- emberCliUpdateJsonPath,
260- blueprint : endBlueprint
261- } ) ;
255+ ignoredFiles : [ await getBlueprintRelativeFilePath ( cwd ) ]
256+ } ) ;
262257
263- if ( ! reset ) {
264- await stageBlueprintFile ( {
265- cwd,
266- emberCliUpdateJsonPath
267- } ) ;
268- }
269- }
258+ return {
259+ promise : ( async ( ) => {
260+ let result = await promise ;
261+
262+ if ( _blueprint || isPersistedBlueprint ) {
263+ await saveBlueprint ( {
264+ emberCliUpdateJsonPath,
265+ blueprint : endBlueprint
266+ } ) ;
267+
268+ if ( ! reset ) {
269+ await stageBlueprintFile ( {
270+ cwd,
271+ emberCliUpdateJsonPath
272+ } ) ;
273+ }
274+ }
270275
271- return result ;
276+ return result ;
277+ } ) ( ) ,
278+ resolveConflictsProcess
279+ } ;
272280} ;
Original file line number Diff line number Diff line change @@ -23,8 +23,7 @@ module.exports = async function init({
2323 to = toDefault ,
2424 resolveConflicts,
2525 reset,
26- blueprintOptions = [ ] ,
27- wasRunAsExecutable
26+ blueprintOptions = [ ]
2827} ) {
2928 let cwd = process . cwd ( ) ;
3029
@@ -100,7 +99,10 @@ module.exports = async function init({
10099 init = true ;
101100 }
102101
103- let result = await ( await boilerplateUpdate ( {
102+ let {
103+ promise,
104+ resolveConflictsProcess
105+ } = await boilerplateUpdate ( {
104106 endVersion : blueprint . version ,
105107 resolveConflicts,
106108 reset,
@@ -113,21 +115,27 @@ module.exports = async function init({
113115 baseBlueprint,
114116 endBlueprint : blueprint
115117 } ) ,
116- ignoredFiles : [ await getBlueprintRelativeFilePath ( cwd ) ] ,
117- wasRunAsExecutable
118- } ) ) . promise ;
119-
120- await saveBlueprint ( {
121- emberCliUpdateJsonPath,
122- blueprint
118+ ignoredFiles : [ await getBlueprintRelativeFilePath ( cwd ) ]
123119 } ) ;
124120
125- if ( ! ( reset || init ) ) {
126- await stageBlueprintFile ( {
127- cwd,
128- emberCliUpdateJsonPath
129- } ) ;
130- }
131-
132- return result ;
121+ return {
122+ promise : ( async ( ) => {
123+ let result = await promise ;
124+
125+ await saveBlueprint ( {
126+ emberCliUpdateJsonPath,
127+ blueprint
128+ } ) ;
129+
130+ if ( ! ( reset || init ) ) {
131+ await stageBlueprintFile ( {
132+ cwd,
133+ emberCliUpdateJsonPath
134+ } ) ;
135+ }
136+
137+ return result ;
138+ } ) ( ) ,
139+ resolveConflictsProcess
140+ } ;
133141} ;
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ describe(function() {
6565 process . chdir ( tmpPath ) ;
6666
6767 let promise = ( async ( ) => {
68- let result = await emberCliUpdate ( {
68+ let result = await ( await emberCliUpdate ( {
6969 blueprint,
7070 from,
7171 to,
@@ -76,7 +76,7 @@ describe(function() {
7676 codemodsJson,
7777 listCodemods,
7878 createCustomDiff
79- } ) ;
79+ } ) ) . promise ;
8080
8181 await afterMerge ( ) ;
8282
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ describe(init, function() {
4848
4949 process . chdir ( tmpPath ) ;
5050
51- let promise = init ( {
51+ let { promise } = await init ( {
5252 blueprint,
5353 to,
5454 blueprintOptions
You can’t perform that action at this time.
0 commit comments