diff --git a/tasks/haxe.js b/tasks/haxe.js index 26f6d88..30ed5ce 100755 --- a/tasks/haxe.js +++ b/tasks/haxe.js @@ -51,6 +51,36 @@ class Haxe extends Sdk { } } + static get pamFile() { + return `${os.homedir()}/.pam_environment`; + } + + checkEnviron() { + if (fs.existsSync(Haxe.pamFile)) { + const data = fs.readFileSync(Haxe.pamFile, 'utf8'); + // ToDo: parse file + if (data.indexOf('HAXE_VERSION')) { + return true; + } + } + return false; + } + + setupEnviron() { + if (this.checkEnviron()) return; + // ToDo: parse file + const haxeVersion = `HAXE_VERSION=${this.version}`; + const haxeStdPath = `HAXE_STD_PATH=${this.binPath}/std`; + const haxeHome = `HAXE_HOME=${this.binPath}`; + const pathDefault = `PATH DEFAULT="\${PATH}:${this.binPath}"`; + const data = [haxeVersion, haxeStdPath, haxeHome, pathDefault, '']; + fs.appendFileSync(Haxe.pamFile, data.join('\n')); + } + + prepare() { + return super.prepare().then(() => this.setupEnviron()); + } + get link() { if (Sdk.System.isWindows) { return `https://github.com/HaxeFoundation/haxe/releases/download/${this.version}/haxe-${this.version}-win.zip`;