This commit is contained in:
2018-07-07 16:30:57 +03:00
parent 820b639427
commit 54830d1d01
4 changed files with 16 additions and 10 deletions

View File

@@ -4,7 +4,6 @@ const fse = require('fs-extra');
const os = require('os');
const through = require('through2');
const Sdk = require('./sdk');
const Vinyl = require('vinyl');
const run = require('../run/index');
const {TailVinyl} = require('./tail');
@@ -68,7 +67,7 @@ class FlashPlayer extends Sdk {
static enableLog() {
const filename = path.join(os.homedir(), 'mm.cfg');
const value = 'TraceOutputFileEnable=1';
if (fs.exists(filename)) {
if (fs.existsSync(filename)) {
const data = fs.readFileSync(filename);
if (data.indexOf(value) === -1) {
fs.appendFileSync(filename, `${value}\n`);
@@ -76,18 +75,19 @@ class FlashPlayer extends Sdk {
} else {
fs.writeFileSync(filename, `${value}\n`);
}
fse.ensureDirSync(path.join(this.flashPlayerDir, 'Logs'));
fs.writeFileSync(FlashPlayer.log, '');
}
static trust(value) {
const filename = path.join(this.flashPlayerDir, '#Security', 'FlashPlayerTrust', 'gulp.cfg');
if (fs.exists(filename)) {
if (fs.existsSync(filename)) {
const data = fs.readFileSync(filename);
if (data.indexOf(value) === -1) {
fs.appendFileSync(filename, `${value}\n`);
}
} else {
if (!fs.exists(path.dirname(filename))) {
if (!fs.existsSync(path.dirname(filename))) {
fse.ensureDirSync(path.dirname(filename));
}
fs.writeFileSync(filename, `${value}\n`);
@@ -117,7 +117,8 @@ FlashPlayer.VERSION_25 = '25';
FlashPlayer.VERSION_26 = '26';
FlashPlayer.VERSION_27 = '27';
FlashPlayer.VERSION_29 = '29';
FlashPlayer.VERSION_30 = '30';
FlashPlayer.VERSION = FlashPlayer.VERSION_29;
FlashPlayer.VERSION = FlashPlayer.VERSION_30;
module.exports = FlashPlayer;

View File

@@ -81,6 +81,7 @@ class Sdk {
} else {
fse.ensureDirSync(this.path);
const bar = new ProgressBar(`${this.tag} [:bar] :percent :etas`, {width: 40, total: 1000, clear: true});
this.log.d('download: *%s*', this.link);
let stream = got.stream(this.link);
stream = stream.on('downloadProgress', (p) => bar.update(p.percent));
if (this.link.endsWith('.zip')) {

View File

@@ -11,13 +11,17 @@ class TailVinyl extends Vinyl {
constructor(params) {
params.contents = new Transform();
super(params);
this.tail = new Tail(params.path);
this.tail.on('line', data => this.contents.write(data + '\n'));
this.tail.on('error', error => this.contents.write('error: ' + error));
if (params.path) {
this.tail = new Tail(params.path);
this.tail.on('line', data => this.contents.write(data + '\n'));
this.tail.on('error', error => this.contents.write('error: ' + error));
}
}
dispose() {
this.tail.unwatch();
if (this.tail) {
this.tail.unwatch();
}
this.contents.destroy();
}
}