[neko] added
This commit is contained in:
@@ -4,11 +4,13 @@ const colors = require('ansi-colors');
|
||||
const log = require('fancy-log');
|
||||
|
||||
const TAG = colors.green('[exec]');
|
||||
const verbose = process.argv.indexOf('--verbose') > -1;
|
||||
|
||||
const queue = async.queue((task, done) => {
|
||||
//log(TAG, colors.magenta(task.command));
|
||||
if (verbose) log(TAG, colors.magenta(task.command));
|
||||
//process.chdir(task.dir);
|
||||
child_process.exec(task.command, {cwd: task.dir, maxBuffer: 1024 * 5000}, (err, stdout, stderr) => {
|
||||
if (verbose) log(TAG, err ? colors.red(err) : '', stdout, colors.red(stderr));
|
||||
if (err) {
|
||||
task.failure(stderr || stdout || err);
|
||||
} else {
|
||||
|
||||
@@ -4,6 +4,7 @@ const fse = require('fs-extra');
|
||||
const path = require('path');
|
||||
const exec = require('./exec');
|
||||
const Sdk = require('./sdk');
|
||||
const Neko = require('./neko');
|
||||
const colors = require('ansi-colors');
|
||||
const log = require('fancy-log');
|
||||
const vfs = require('vinyl-fs');
|
||||
@@ -39,6 +40,7 @@ class Haxe extends Sdk {
|
||||
|
||||
constructor(version) {
|
||||
super(Haxe.ID, version || Haxe.VERSION);
|
||||
this.neko = new Neko();
|
||||
}
|
||||
|
||||
get prepared() {
|
||||
@@ -50,6 +52,7 @@ class Haxe extends Sdk {
|
||||
}
|
||||
|
||||
activate() {
|
||||
this.neko.activate()
|
||||
process.env.HAXE_VERSION = this.version;
|
||||
process.env.HAXE_STD_PATH = path.join(this.binPath, 'std');
|
||||
process.env.HAXE_HOME = this.binPath;
|
||||
@@ -59,7 +62,7 @@ class Haxe extends Sdk {
|
||||
}
|
||||
|
||||
prepare() {
|
||||
return super.prepare().then(() => this.activate());
|
||||
return Promise.all([this.neko.prepare(), super.prepare()]);
|
||||
}
|
||||
|
||||
get link() {
|
||||
@@ -81,6 +84,7 @@ class Haxe extends Sdk {
|
||||
|
||||
openfl(command, platform, config, debug=false) {
|
||||
log(this.tag, colors.cyan(`openfl build ${platform}`));
|
||||
this.activate()
|
||||
const buildDir = path.join(os.tmpdir(), 'build', config.name);
|
||||
fse.ensureDirSync(buildDir);
|
||||
|
||||
@@ -99,6 +103,7 @@ class Haxe extends Sdk {
|
||||
|
||||
build(platform, config, debug=false) {
|
||||
log(this.tag, colors.cyan(`build ${platform}`));
|
||||
this.activate()
|
||||
const buildDir = path.join(os.tmpdir(), 'build', config.name);
|
||||
fse.ensureDirSync(buildDir);
|
||||
|
||||
@@ -130,6 +135,7 @@ class Haxe extends Sdk {
|
||||
}
|
||||
|
||||
install(packages) {
|
||||
this.activate()
|
||||
let promise = this.haxelib(['setup', path.join(this.path, 'lib')]);
|
||||
const next = (args) => () => {
|
||||
log(this.tag, colors.cyan('haxelib', 'install'), colors.magenta(args[1]));
|
||||
|
||||
83
haxetool/neko.js
Normal file
83
haxetool/neko.js
Normal file
@@ -0,0 +1,83 @@
|
||||
const os = require('os');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const run = require('../run/index');
|
||||
const Sdk = require('./sdk');
|
||||
const System = Sdk.System;
|
||||
|
||||
|
||||
class NekoLink {
|
||||
|
||||
static get type() {
|
||||
switch (os.type()) {
|
||||
case 'Linux': return 'linux';
|
||||
case 'Windows_NT': return 'win';
|
||||
}
|
||||
}
|
||||
|
||||
static get arch() {
|
||||
switch (os.arch()) {
|
||||
case 'ia32': return '';
|
||||
case 'x64': return '64';
|
||||
}
|
||||
}
|
||||
|
||||
static get ext() {
|
||||
switch (os.type()) {
|
||||
case 'Linux': return 'tar.gz';
|
||||
case 'Windows_NT': return 'zip';
|
||||
}
|
||||
}
|
||||
|
||||
static get(version) {
|
||||
const vv = version.split('\.').join('-');
|
||||
const filename = `neko-${version}-${NekoLink.type}${NekoLink.arch}.${NekoLink.ext}`;
|
||||
return `https://github.com/HaxeFoundation/neko/releases/download/v${vv}/${filename}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Neko extends Sdk {
|
||||
|
||||
constructor(version) {
|
||||
super(Neko.ID, version || Neko.VERSION);
|
||||
}
|
||||
|
||||
get link() {
|
||||
return NekoLink.get(this.version);
|
||||
}
|
||||
|
||||
get prepared() {
|
||||
try {
|
||||
return fs.existsSync(this.nekoBin);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
activate() {
|
||||
process.env.NEKO_INSTPATH = this.path;
|
||||
if (process.env.PATH.split(path.delimiter).indexOf(this.path) === -1) {
|
||||
process.env.PATH = [process.env.PATH, this.path].join(path.delimiter);
|
||||
}
|
||||
}
|
||||
|
||||
get nekoBin() {
|
||||
let binname = 'neko';
|
||||
if (os.type() == 'Windows_NT') binname += '.exe';
|
||||
return path.join(this.path, binname);
|
||||
}
|
||||
|
||||
run(filename, params) {
|
||||
this.activate();
|
||||
console.log(`${this.nekoBin} ${filename}`);
|
||||
return run(`${this.nekoBin} ${filename}`, params).exec();
|
||||
}
|
||||
}
|
||||
|
||||
Neko.ID = 'neko'
|
||||
|
||||
Neko.VERSION_2_2_0 = '2.2.0';
|
||||
Neko.VERSION = Neko.VERSION_2_2_0;
|
||||
|
||||
module.exports = Neko;
|
||||
@@ -5,6 +5,7 @@ const fs = require('fs');
|
||||
const fse = require('fs-extra');
|
||||
const Haxe = require('./haxe');
|
||||
const FlashPlayer = require('./flashplayer');
|
||||
const Neko = require('./neko');
|
||||
const debug = require('./debug');
|
||||
const webserver = require('gulp-webserver');
|
||||
const run = require('../run/index');
|
||||
@@ -311,12 +312,17 @@ class NekoRunner extends Runner {
|
||||
|
||||
constructor(config, debug) {
|
||||
super(config, Platform.NEKO, debug);
|
||||
this.neko = new Neko();
|
||||
}
|
||||
|
||||
prepare() {
|
||||
return this.neko.prepare();
|
||||
}
|
||||
|
||||
call() {
|
||||
const target = this.targetPath;
|
||||
const filename = path.resolve(target, this.config.meta.filename+'.n');
|
||||
const result = gulp.src(filename).pipe(run("neko <%=file.path%>", {cwd: target}));
|
||||
const result = this.neko.run(filename, {cwd: target, verbosity: 0});
|
||||
return this.log(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ class Sdk {
|
||||
} else if (this.link.endsWith('tar.gz')) {
|
||||
stream = stream.pipe(tar.x({C: this.path, strip: strip}));
|
||||
} else {
|
||||
stream = stream.pipe(fs.createWriteStream(this.path));
|
||||
stream = stream.pipe(fs.createWriteStream(path.join(this.path, this.link.split('/').pop())));
|
||||
}
|
||||
return ps.wait(stream);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user