[haxe] fixes for windows compatibility

This commit is contained in:
2018-04-27 15:36:15 +03:00
parent 251d2fea1e
commit 22a371292f
5 changed files with 33 additions and 19 deletions

View File

@@ -1,3 +1,4 @@
const os = require('os');
const path = require('path');
@@ -43,17 +44,21 @@ class Config {
}
}
static absolutePath(file) {
const result = path.resolve(process.cwd(), path.normalize(file));
return os.type() === 'Windows_NT' ? result.split('\\').join('/') : result;
}
update(params) {
this._params.push(params);
if (params.name !== undefined) this.name = params.name;
if (params.main !== undefined) this.main = params.main;
const cwd = process.cwd();
if (params.sources !== undefined) this.sources = this.sources.concat(params.sources.map(item => path.resolve(cwd, item)));
if (params.assets !== undefined) this.assets = this.assets.concat(params.assets.map(item => path.resolve(cwd, item)));
if (params.sources !== undefined) this.sources = this.sources.concat(params.sources.map(Config.absolutePath));
if (params.assets !== undefined) this.assets = this.assets.concat(params.assets.map(Config.absolutePath));
if (params.libs !== undefined) this.libs = this.libs.concat(Array.isArray(params.libs) ? params.libs : Object.entries(params.libs).map(([k, v]) => ({name: k, version: v})));
if (params.macros !== undefined) this.macros = this.macros.concat(params.macros);
if (params.meta !== undefined) this.meta = {...this.meta, ...params.meta};
if (this.meta.icon) this.icon = path.resolve(cwd, this.meta.icon)
if (this.meta.icon) this.icon = Config.absolutePath(this.meta.icon);
}
branch(params) {