[haxe] fixes for windows compatibility
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const ps = require('promise-streams');
|
||||
const got = require('got');
|
||||
@@ -41,11 +42,11 @@ class Sdk {
|
||||
}
|
||||
|
||||
static get dir() {
|
||||
return Sdk._dir || `${os.homedir()}/sdk`;
|
||||
return Sdk._dir || path.join(os.homedir(), 'sdk');
|
||||
}
|
||||
|
||||
static path(name, version) {
|
||||
return `${this.dir}/${name}/${version}`;
|
||||
return path.join(this.dir, name, version);
|
||||
}
|
||||
|
||||
constructor(name, version) {
|
||||
@@ -85,14 +86,13 @@ class Sdk {
|
||||
let stream = got.stream(this.link);
|
||||
stream = stream.on('downloadProgress', (p) => bar.update(p.percent));
|
||||
if (this.link.endsWith('.zip')) {
|
||||
const sep = '/';
|
||||
stream = stream.pipe(unzip.Parse()).on('entry', (entry) => {
|
||||
const filePath = entry.path.split(sep).slice(1).join(sep);
|
||||
const filePath = entry.path.split('/').slice(1).join(path.sep);
|
||||
if (filePath.length > 0) {
|
||||
if (entry.type === 'Directory') {
|
||||
mkdirp(this.path + sep + filePath);
|
||||
mkdirp(path.join(this.path, path.normalize(filePath)));
|
||||
} else if (entry.type === 'File') {
|
||||
entry.pipe(fs.createWriteStream(this.path + sep + filePath));
|
||||
entry.pipe(fs.createWriteStream(path.join(this.path, path.normalize(filePath))));
|
||||
}
|
||||
} else {
|
||||
entry.autodrain();
|
||||
|
||||
Reference in New Issue
Block a user