[build] generate proto clasess
This commit is contained in:
32
tasks/sdk.js
32
tasks/sdk.js
@@ -3,11 +3,37 @@ const fs = require('fs');
|
||||
const ps = require('promise-streams');
|
||||
const got = require('got');
|
||||
const unzip = require('unzip-stream');
|
||||
const tar = require('tar');
|
||||
const ProgressBar = require('progress');
|
||||
const colors = require('ansi-colors');
|
||||
const log = require('fancy-log');
|
||||
|
||||
|
||||
class System {
|
||||
|
||||
static get isWindows() {
|
||||
return os.type() === 'Windows_NT';
|
||||
}
|
||||
|
||||
static get isLinux() {
|
||||
return os.type() === 'Linux';
|
||||
}
|
||||
|
||||
static get archInt() {
|
||||
if (os.arch() === 'ia32') return 32;
|
||||
if (os.arch() === 'x64') return 64;
|
||||
}
|
||||
|
||||
static get isArch32() {
|
||||
return this.archInt === 32;
|
||||
}
|
||||
|
||||
static get isArch64() {
|
||||
return this.archInt === 64;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Sdk {
|
||||
static set dir(value) {
|
||||
Sdk._dir = value
|
||||
@@ -56,12 +82,10 @@ class Sdk {
|
||||
const bar = new ProgressBar(`${this.tag} [:bar] :percent :etas`, {width: 40, total: 1000, clear: true});
|
||||
let stream = got.stream(this.link);
|
||||
stream = stream.on('downloadProgress', (p) => bar.update(p.percent));
|
||||
//stream = stream.pipe(fs.createWriteStream(this.path + '.zip'));
|
||||
if (this.link.endsWith('.zip')) {
|
||||
stream = stream.pipe(unzip.Extract({path: this.path}));
|
||||
} else if (this.link.endsWith('tar.gz')) {
|
||||
// ToDo: unpack tar.gz
|
||||
//stream = stream.pipe(gunzip()).pipe(untar())
|
||||
stream = stream.pipe(tar.x({C: this.path}));
|
||||
} else {
|
||||
stream = stream.pipe(fs.createWriteStream(this.path));
|
||||
}
|
||||
@@ -70,4 +94,6 @@ class Sdk {
|
||||
}
|
||||
}
|
||||
|
||||
Sdk.System = System;
|
||||
|
||||
module.exports = Sdk;
|
||||
Reference in New Issue
Block a user