mirror of
https://github.com/nuintun/command-manager.git
synced 2025-06-07 19:44:35 +08:00
update files
This commit is contained in:
parent
e974150bb3
commit
700c728b28
@ -1,64 +0,0 @@
|
|||||||
/**
|
|
||||||
* Created by nuintun on 2015/12/4.
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var Emulator = require('./emulator');
|
|
||||||
|
|
||||||
var emulator;
|
|
||||||
|
|
||||||
// thread
|
|
||||||
process.on('message', function (message){
|
|
||||||
if (message.action === 'stop') {
|
|
||||||
if (emulator) {
|
|
||||||
emulator.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
process.exit();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message.action === 'start') {
|
|
||||||
var stream;
|
|
||||||
var project = message.project;
|
|
||||||
|
|
||||||
if (emulator) {
|
|
||||||
emulator.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
emulator = new Emulator({
|
|
||||||
cwd: project.path,
|
|
||||||
command: project.command.value
|
|
||||||
});
|
|
||||||
|
|
||||||
stream = emulator.start();
|
|
||||||
|
|
||||||
stream.stdout.on('data', function (data){
|
|
||||||
process.send({
|
|
||||||
event: 'data',
|
|
||||||
project: project,
|
|
||||||
data: data.toString()
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
stream.stderr.on('data', function (error){
|
|
||||||
emulator.stop();
|
|
||||||
process.send({
|
|
||||||
event: 'error',
|
|
||||||
project: project,
|
|
||||||
data: error.toString()
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
stream.on('close', function (signal){
|
|
||||||
emulator.stop();
|
|
||||||
process.send({
|
|
||||||
event: 'close',
|
|
||||||
project: project,
|
|
||||||
data: signal.toString()
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
Loading…
x
Reference in New Issue
Block a user