mirror of
https://github.com/nuintun/command-manager.git
synced 2025-06-07 11:34:05 +08:00
update files
This commit is contained in:
parent
d78f57735d
commit
7a3836ada5
45
bin/child-thread.js
Normal file
45
bin/child-thread.js
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/**
|
||||||
|
* Created by nuintun on 2015/12/4.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var Emulator = require('./emulator');
|
||||||
|
|
||||||
|
// thread
|
||||||
|
process.on('message', function (project){
|
||||||
|
var stream;
|
||||||
|
|
||||||
|
var 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()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -69,40 +69,4 @@ function normalizeExecArgs(command, options){
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// thread
|
module.exports = Emulator;
|
||||||
process.on('message', function (project){
|
|
||||||
var stream;
|
|
||||||
|
|
||||||
var 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()
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
@ -44,7 +44,7 @@ module.exports = {
|
|||||||
env[item.name] = item.value;
|
env[item.name] = item.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
thread = fork(path.join(__dirname, 'emulator'), {
|
thread = fork(path.join(__dirname, 'child-thread'), {
|
||||||
env: env
|
env: env
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user