added log module
This commit is contained in:
@@ -4,11 +4,8 @@ const fse = require('fs-extra');
|
||||
const os = require('os');
|
||||
const through = require('through2');
|
||||
const Sdk = require('./sdk');
|
||||
const exec = require('./exec');
|
||||
const PluginError = require('plugin-error');
|
||||
const colors = require('ansi-colors');
|
||||
const log = require('fancy-log');
|
||||
const Vinyl = require('vinyl');
|
||||
const run = require('../run/index');
|
||||
|
||||
|
||||
class FlashPlayer extends Sdk {
|
||||
@@ -78,6 +75,7 @@ class FlashPlayer extends Sdk {
|
||||
} else {
|
||||
fs.writeFileSync(filename, `${value}\n`);
|
||||
}
|
||||
fs.writeFileSync(FlashPlayer.log, '');
|
||||
}
|
||||
|
||||
static trust(value) {
|
||||
@@ -95,29 +93,15 @@ class FlashPlayer extends Sdk {
|
||||
}
|
||||
}
|
||||
|
||||
run() {
|
||||
let stream = null;
|
||||
const bufferContents = (file, enc, callback) => {
|
||||
log(this.tag, colors.cyan("run"), colors.magenta(file.path));
|
||||
FlashPlayer.trust(file.path);
|
||||
FlashPlayer.enableLog();
|
||||
exec('.', [this.flashPlayerBin, file.path].join(' ')).then(() => {
|
||||
stream.emit('end');
|
||||
run(filename, params) {
|
||||
this.log.i('_run_ *%s*', filename);
|
||||
FlashPlayer.trust(filename);
|
||||
FlashPlayer.enableLog();
|
||||
return run(`${this.flashPlayerBin} ${filename}`, params).exec()
|
||||
.pipe(through.obj(function (file, enc, callback) {
|
||||
this.push(new Vinyl({path: FlashPlayer.log}));
|
||||
callback();
|
||||
}).catch((error) => {
|
||||
stream.emit('error', new PluginError({plugin: this.tag, message: error}));
|
||||
callback();
|
||||
});
|
||||
//stream.push(file);
|
||||
// ToDo: watch when file is exists
|
||||
// or create log file in FlashPlayer.enableLog()?
|
||||
stream.push(new Vinyl({
|
||||
path: FlashPlayer.log
|
||||
}));
|
||||
//stream.push(file);
|
||||
};
|
||||
|
||||
return stream = through.obj(bufferContents);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user