forked from Kode/khamake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHaxe.js
32 lines (27 loc) · 1.09 KB
/
Haxe.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"use strict";
const child_process = require('child_process');
const fs = require('fs');
const path = require('path');
const log = require('./log.js');
const exec = require('./exec.js');
exports.executeHaxe = function (from, haxeDirectory, options) {
let exe = 'haxe';
let env = process.env;
if (fs.existsSync(haxeDirectory.toString()) && fs.statSync(haxeDirectory.toString()).isDirectory()) {
let localexe = haxeDirectory.resolve('haxe' + exec.sys()).toAbsolutePath().toString();
if (!fs.existsSync(localexe)) localexe = haxeDirectory.resolve('haxe').toAbsolutePath().toString();
if (fs.existsSync(localexe)) exe = localexe;
const stddir = haxeDirectory.toAbsolutePath().resolve('std').toString();
if (fs.existsSync(stddir) && fs.statSync(stddir).isDirectory()) {
env.HAXE_STD_PATH = stddir;
}
}
let result = child_process.spawnSync(exe, options, { env: env, cwd: path.normalize(from.toString()) });
if (result.stdout.toString() !== '') {
log.info(result.stdout.toString());
}
if (result.stderr.toString() !== '') {
log.error(result.stderr.toString());
}
return result.status;
};