1
- const { execSync} = require ( "child_process" ) ;
1
+ const { execSync, spawnSync } = require ( "child_process" ) ;
2
2
const path = require ( "path" ) ;
3
3
const process = require ( "process" ) ;
4
4
const fs = require ( "fs" ) ;
@@ -40,6 +40,11 @@ qx.Class.define("qxl.packagebrowser.compile.LibraryApi", {
40
40
console . log ( ">>> Package data exists." ) ;
41
41
return ;
42
42
}
43
+
44
+ let s = 'npm install --no-save --no-package-lock mkdirp' ;
45
+ console . info ( s ) ;
46
+ execSync ( s ) ;
47
+ const mkdirp = require ( 'mkdirp' ) ;
43
48
44
49
const header = " Creating metadata for package browser. This will take a while. " ;
45
50
console . log ( ) ;
@@ -80,8 +85,7 @@ qx.Class.define("qxl.packagebrowser.compile.LibraryApi", {
80
85
for ( let pkg of packages ) {
81
86
this . __addCmd ( `qx pkg install ${ pkg } ` , `Installing ${ pkg } ...` , containerPath ) ;
82
87
}
83
- await this . __executeCommands ( ) ;
84
- const packages_dir = path . join ( containerPath , "qx_packages" ) ;
88
+ this . __executeCommands ( ) ;
85
89
const lockfile_data = await this . __loadJson ( path . join ( containerPath , "qx-lock.json" ) ) ;
86
90
const packages_data = await this . __loadJson ( datafilePath ) ;
87
91
console . log ( `\n>>> Preparing compilation. Please check the following messages for errors and warnings.` ) ;
@@ -129,19 +133,19 @@ qx.Class.define("qxl.packagebrowser.compile.LibraryApi", {
129
133
}
130
134
// compile the application
131
135
this . __addCmd (
132
- `qx pkg migrate 2>&1 && qx compile --target=${ targetType } --warnAsError=false --feedback=0 --force 2>&1 ` ,
136
+ `qx pkg migrate && qx compile --target=${ targetType } --warnAsError=false --feedback=0 --force ` ,
133
137
`Compiling ${ manifest . info . name } v${ manifest . info . version } ...` ,
134
138
pkg_dir ,
135
139
( stdout , stderr ) => {
136
- let compilation_log = stdout + "\n\n" + stderr ;
140
+ let compilation_log = stdout + "\n\n" + stderr ;
137
141
packages_data [ index ] . data = {
138
142
problems : Boolean ( compilation_log . match ( / ( e r r o r | w a r n | m i s s i n g | f a i l e d | c a n n o t f i n d | u n r e s o l v e d | u n e x p e c t e d | d e p r e c a t e d ) / i) ) ,
139
143
compilation_log
140
144
} ;
141
145
let target = compileData . targets . find ( target => target . type === targetType ) || compileData . targets [ 0 ] ;
142
146
let outputPath = path . join ( pkg_dir , target . outputPath ) ;
143
147
let appTgtPath = path . join ( targetDir , pkg_data . uri ) ;
144
- this . __mkdirp ( appTgtPath ) ;
148
+ mkdirp . sync ( path . dirname ( appTgtPath ) ) ;
145
149
/* transpiled is needed for apiviewer
146
150
if (targetType === "build") {
147
151
this.__deleteFolderRecursiveSync(path.join(outputPath, "transpiled"));
@@ -153,7 +157,7 @@ qx.Class.define("qxl.packagebrowser.compile.LibraryApi", {
153
157
packages_data [ index ] . data . applications = compileData . applications ;
154
158
} ,
155
159
error => {
156
- let compilation_log = error . message + "\n\n" + error . stderr . toString ( ) + "\n\n" + error . stdout . toString ( ) ;
160
+ let compilation_log = error . message + "\n\n" + error . stderr + "\n\n" + error . stdout ;
157
161
console . error ( compilation_log ) ;
158
162
packages_data [ index ] . data = {
159
163
problems : true ,
@@ -162,7 +166,7 @@ qx.Class.define("qxl.packagebrowser.compile.LibraryApi", {
162
166
}
163
167
) ;
164
168
}
165
- await this . __executeCommands ( ) ;
169
+ this . __executeCommands ( ) ;
166
170
await qx . tool . utils . Json . saveJsonAsync ( datafilePath , packages_data . filter ( pkg => Boolean ( pkg ) ) ) ;
167
171
this . __pkgDataGenerated = true ;
168
172
console . log ( "\n>>> Done." ) ;
@@ -204,24 +208,33 @@ qx.Class.define("qxl.packagebrowser.compile.LibraryApi", {
204
208
* Executes the commands in the queue.
205
209
* @private
206
210
*/
207
- async __executeCommands ( ) {
211
+ __executeCommands ( ) {
208
212
for ( let [ cmd , info , cwd , onSuccess , onFail ] of this . __cmds ) {
209
213
console . log ( ">>> " + ( info || `Executing '${ cmd } '` ) ) ;
210
214
const options = { } ;
211
215
if ( cwd ) {
212
216
options . cwd = cwd ;
213
217
}
218
+ options . shell = true ;
219
+ let sout ;
220
+ let serr ;
214
221
try {
215
- let stdout = execSync ( cmd , options ) ;
216
- stdout = stdout . toString ( ) . trim ( ) ;
217
- if ( stdout ) {
218
- console . log ( stdout ) ;
222
+ let { stdout, stderr} = spawnSync ( cmd , options ) ;
223
+ sout = stdout . toString ( ) . trim ( ) ;
224
+ if ( sout ) {
225
+ console . log ( sout ) ;
226
+ }
227
+ serr = stderr . toString ( ) . trim ( ) ;
228
+ if ( serr ) {
229
+ console . log ( serr ) ;
219
230
}
220
231
if ( typeof onSuccess == "function" ) {
221
- onSuccess ( stdout , "" ) ;
232
+ onSuccess ( sout , serr ) ;
222
233
}
223
234
} catch ( e ) {
224
235
if ( typeof onFail == "function" ) {
236
+ e . stdout = sout ;
237
+ e . stderr = serr ;
225
238
onFail ( e ) ;
226
239
} else {
227
240
throw e ;
@@ -232,22 +245,6 @@ qx.Class.define("qxl.packagebrowser.compile.LibraryApi", {
232
245
this . __cmds = [ ] ;
233
246
} ,
234
247
235
- /**
236
- * Equivalent for `mkdir -p` on bash
237
- * @param {String } targetDir
238
- * @private
239
- */
240
- __mkdirp ( targetDir ) {
241
- const initDir = path . isAbsolute ( targetDir ) ? '/' : '' ;
242
- targetDir . split ( "/" ) . reduce ( ( parentDir , childDir ) => {
243
- const curDir = path . resolve ( parentDir , childDir ) ;
244
- if ( ! fs . existsSync ( curDir ) ) {
245
- fs . mkdirSync ( curDir ) ;
246
- }
247
- return curDir ;
248
- } , initDir ) ;
249
- } ,
250
-
251
248
/**
252
249
* Equivalent for `rm -rf` on bash
253
250
* @param {String } file_path
0 commit comments