[project] added
This commit is contained in:
67
haxetool/core.js
Normal file
67
haxetool/core.js
Normal file
@@ -0,0 +1,67 @@
|
||||
const path = require('path');
|
||||
|
||||
|
||||
const BuildSystem = {
|
||||
HAXE: 'haxe',
|
||||
OPENFL: 'openfl',
|
||||
ADOBE_AIR: 'adobe_air',
|
||||
};
|
||||
|
||||
|
||||
const Platform = {
|
||||
FLASH: 'flash',
|
||||
HTML5: 'html5',
|
||||
LINUX: 'linux',
|
||||
WINDOWS: 'windows',
|
||||
ANDROID: 'android',
|
||||
NEKO: 'neko',
|
||||
};
|
||||
|
||||
|
||||
class Config {
|
||||
|
||||
constructor(params) {
|
||||
this._params = [];
|
||||
this.name = null;
|
||||
this.main = null;
|
||||
this.sources = [];
|
||||
this.assets = [];
|
||||
this.libs = [];
|
||||
this.meta = {
|
||||
title: null,
|
||||
version: null,
|
||||
pack: null,
|
||||
company:null
|
||||
};
|
||||
if (params) {
|
||||
this.update(params);
|
||||
}
|
||||
}
|
||||
|
||||
update(params) {
|
||||
this._params.push(params);
|
||||
if (params.name !== undefined) this.name = params.name;
|
||||
if (params.name !== 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.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.meta !== undefined) this.meta = {...this.meta, ...params.meta};
|
||||
}
|
||||
|
||||
branch(params) {
|
||||
const result = new Config();
|
||||
for (const params of this._params) {
|
||||
result.update(params);
|
||||
}
|
||||
result.update(params);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
BuildSystem: BuildSystem,
|
||||
Platform: Platform,
|
||||
Config: Config,
|
||||
};
|
||||
Reference in New Issue
Block a user