Skip to content

Commit 1b2ec96

Browse files
authored
Merge pull request #1 from qooxdoo/hkollmann_windows
with this changes the packagebrowser compiles in windows enviroment too.
2 parents e98b60c + fc62134 commit 1b2ec96

File tree

2 files changed

+28
-30
lines changed

2 files changed

+28
-30
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
/compiled
33
/qx_packages
44
/packages
5+
/node_modules
56
.idea
67
.DS_Store

compile.js

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const {execSync} = require("child_process");
1+
const {execSync, spawnSync} = require("child_process");
22
const path = require("path");
33
const process = require("process");
44
const fs = require("fs");
@@ -40,6 +40,11 @@ qx.Class.define("qxl.packagebrowser.compile.LibraryApi", {
4040
console.log(">>> Package data exists.");
4141
return;
4242
}
43+
44+
let s = 'npm install --no-save --no-package-lock mkdirp';
45+
console.info(s);
46+
execSync(s);
47+
const mkdirp = require('mkdirp');
4348

4449
const header = " Creating metadata for package browser. This will take a while. ";
4550
console.log();
@@ -80,8 +85,7 @@ qx.Class.define("qxl.packagebrowser.compile.LibraryApi", {
8085
for (let pkg of packages) {
8186
this.__addCmd(`qx pkg install ${pkg}`, `Installing ${pkg}...`, containerPath);
8287
}
83-
await this.__executeCommands();
84-
const packages_dir = path.join(containerPath, "qx_packages");
88+
this.__executeCommands();
8589
const lockfile_data = await this.__loadJson(path.join(containerPath, "qx-lock.json"));
8690
const packages_data = await this.__loadJson(datafilePath);
8791
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", {
129133
}
130134
// compile the application
131135
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 `,
133137
`Compiling ${manifest.info.name} v${manifest.info.version}...`,
134138
pkg_dir,
135139
(stdout, stderr) => {
136-
let compilation_log = stdout + "\n\n" +stderr;
140+
let compilation_log = stdout + "\n\n" + stderr;
137141
packages_data[index].data = {
138142
problems: Boolean(compilation_log.match(/(error|warn|missing|failed|cannot find|unresolved|unexpected|deprecated)/i)),
139143
compilation_log
140144
};
141145
let target = compileData.targets.find(target => target.type === targetType) || compileData.targets[0];
142146
let outputPath = path.join(pkg_dir, target.outputPath);
143147
let appTgtPath = path.join(targetDir, pkg_data.uri);
144-
this.__mkdirp(appTgtPath);
148+
mkdirp.sync(path.dirname(appTgtPath));
145149
/* transpiled is needed for apiviewer
146150
if (targetType === "build") {
147151
this.__deleteFolderRecursiveSync(path.join(outputPath, "transpiled"));
@@ -153,7 +157,7 @@ qx.Class.define("qxl.packagebrowser.compile.LibraryApi", {
153157
packages_data[index].data.applications = compileData.applications;
154158
},
155159
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;
157161
console.error(compilation_log);
158162
packages_data[index].data = {
159163
problems: true,
@@ -162,7 +166,7 @@ qx.Class.define("qxl.packagebrowser.compile.LibraryApi", {
162166
}
163167
);
164168
}
165-
await this.__executeCommands();
169+
this.__executeCommands();
166170
await qx.tool.utils.Json.saveJsonAsync(datafilePath, packages_data.filter(pkg => Boolean(pkg)));
167171
this.__pkgDataGenerated = true;
168172
console.log("\n>>> Done.");
@@ -204,24 +208,33 @@ qx.Class.define("qxl.packagebrowser.compile.LibraryApi", {
204208
* Executes the commands in the queue.
205209
* @private
206210
*/
207-
async __executeCommands() {
211+
__executeCommands() {
208212
for (let [cmd, info, cwd, onSuccess, onFail] of this.__cmds){
209213
console.log( ">>> " + (info || `Executing '${cmd}'`));
210214
const options = {};
211215
if (cwd) {
212216
options.cwd = cwd;
213217
}
218+
options.shell = true;
219+
let sout;
220+
let serr;
214221
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);
219230
}
220231
if (typeof onSuccess == "function") {
221-
onSuccess(stdout,"");
232+
onSuccess(sout, serr);
222233
}
223234
} catch (e) {
224235
if (typeof onFail == "function") {
236+
e.stdout = sout;
237+
e.stderr = serr;
225238
onFail(e);
226239
} else {
227240
throw e;
@@ -232,22 +245,6 @@ qx.Class.define("qxl.packagebrowser.compile.LibraryApi", {
232245
this.__cmds = [];
233246
},
234247

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-
251248
/**
252249
* Equivalent for `rm -rf` on bash
253250
* @param {String} file_path

0 commit comments

Comments
 (0)