Don't spawn subprocess in mocha before()

This commit is contained in:
Rikki Gibson 2018-05-10 15:50:56 -07:00
Родитель 13d95979b1
Коммит e0770d8020
1 изменённых файлов: 18 добавлений и 14 удалений

Просмотреть файл

@ -6,19 +6,23 @@ import * as path from "path";
let serverProcess: childProcess.ChildProcess;
before(function(done) {
serverProcess = childProcess.spawn(path.join(__dirname, "../../node_modules/.bin/ts-node"), ["testserver", "--no-webpack"], { shell: true });
const dataListener = function(data: Buffer) {
console.log(data.toString("utf-8"));
serverProcess.stdout.removeListener("data", dataListener);
done();
};
// TODO: figure out why this hangs on Windows
const flag = false;
if (flag) {
before(function(done) {
serverProcess = childProcess.spawn(path.join(__dirname, "../../node_modules/.bin/ts-node"), ["testserver", "--no-webpack"], { shell: true });
const dataListener = function(data: Buffer) {
console.log(data.toString("utf-8"));
serverProcess.stdout.removeListener("data", dataListener);
done();
};
serverProcess.stdout.on("data", dataListener);
serverProcess.stderr.on("data", dataListener);
serverProcess.on("error", function(err) { done(err); });
});
serverProcess.stdout.on("data", dataListener);
serverProcess.stderr.on("data", dataListener);
serverProcess.on("error", function(err) { done(err); });
});
after(function() {
serverProcess.kill();
});
after(function() {
serverProcess.kill();
});
}