[build] added html5 task
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
const os = require('os');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const tmp = require('tmp-file');
|
||||
@@ -9,6 +10,7 @@ const Vinyl = require('vinyl');
|
||||
const PluginError = require('plugin-error');
|
||||
const colors = require('ansi-colors');
|
||||
const log = require('fancy-log');
|
||||
const vfs = require('vinyl-fs');
|
||||
|
||||
|
||||
class Haxe extends Sdk {
|
||||
@@ -136,7 +138,7 @@ class Haxe extends Sdk {
|
||||
};
|
||||
|
||||
const endStream = (callback) => {
|
||||
log(this.tag, colors.cyan("openfl", params.command, params.platform), '=>', colors.magenta(params.outputFile));
|
||||
log(this.tag, colors.cyan(`openfl ${params.command} ${params.platform}`));
|
||||
const args = ['-cwd', files[0].path, 'run', 'openfl', params.command, params.platform];
|
||||
if (params.values) for (let key of Object.keys(params.values)) {
|
||||
const value = params.values[key];
|
||||
@@ -146,11 +148,11 @@ class Haxe extends Sdk {
|
||||
args.push(`-D${key}="${value}"`);
|
||||
}
|
||||
}
|
||||
const tmpFile = tmp.generateFile();
|
||||
const dir = path.dirname(tmpFile.path);
|
||||
const name = path.basename(tmpFile.path);
|
||||
args.push(`--app-path=${dir}`);
|
||||
args.push(`--app-file=${name}`);
|
||||
const buildDir = path.join(os.tmpdir(), 'build');
|
||||
args.push(`--app-path=${buildDir}`);
|
||||
if (params.outputFile) {
|
||||
args.push(`--app-file=${params.outputFile}`);
|
||||
}
|
||||
if (params.version) args.push(`--meta-version=${params.version}`);
|
||||
//if (params.build) args.push(`--haxedef=BUILD="${params.build}"`);
|
||||
args.push(`--haxeflag="--macro CompilationOption.set('build','${params.build}')"`);
|
||||
@@ -166,14 +168,19 @@ class Haxe extends Sdk {
|
||||
}
|
||||
//console.log('haxelib', args.join(' '));
|
||||
this.haxelib(args).then(() => {
|
||||
const out = new Vinyl({
|
||||
path: params.outputFile,
|
||||
//contents: fs.createReadStream(`${dir}/flash/bin/${name}.swf`),
|
||||
contents: fs.readFileSync(`${dir}/flash/bin/${name}.swf`),
|
||||
});
|
||||
out.debug = debug;
|
||||
stream.push(out);
|
||||
callback();
|
||||
const result = {
|
||||
'flash': `${buildDir}/flash/bin/*.swf`,
|
||||
'html5': `${buildDir}/html5/bin/**/*`,
|
||||
}[params.platform];
|
||||
vfs.src(result).pipe(through.obj((file, enc, cb) => {
|
||||
file.debug = debug;
|
||||
stream.push(file);
|
||||
cb();
|
||||
}, (cb) => {
|
||||
callback();
|
||||
cb();
|
||||
}));
|
||||
//callback();
|
||||
}).catch((error) => {
|
||||
stream.emit('error', new PluginError({plugin: this.name, message: error}));
|
||||
callback();
|
||||
|
||||
Reference in New Issue
Block a user