fix: streams
This commit is contained in:
parent
f07af8fe6e
commit
3db7bb423f
|
@ -1,5 +1,6 @@
|
||||||
const {access} = require('fs/promises');
|
const {access} = require('fs/promises');
|
||||||
const {join} = require('path');
|
const {join} = require('path');
|
||||||
|
const {PassThrough} = require('stream');
|
||||||
|
|
||||||
const {hook: coreCommands} = require('@flecks/build/build/hooks/@flecks/build.commands');
|
const {hook: coreCommands} = require('@flecks/build/build/hooks/@flecks/build.commands');
|
||||||
const {rimraf} = require('@flecks/build/src/server');
|
const {rimraf} = require('@flecks/build/src/server');
|
||||||
|
@ -58,6 +59,7 @@ module.exports = (program, flecks) => {
|
||||||
'test',
|
'test',
|
||||||
{
|
{
|
||||||
env: {
|
env: {
|
||||||
|
DEBUG_COLORS: 'dumb' !== TERM,
|
||||||
FORCE_COLOR: 'dumb' !== TERM,
|
FORCE_COLOR: 'dumb' !== TERM,
|
||||||
},
|
},
|
||||||
production,
|
production,
|
||||||
|
@ -66,9 +68,9 @@ module.exports = (program, flecks) => {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (!watch) {
|
if (!watch) {
|
||||||
const stdout = pipesink(child.stdout);
|
const stdio = pipesink(child.stderr.pipe(child.stdout.pipe(new PassThrough())));
|
||||||
if (0 !== await processCode(child)) {
|
if (0 !== await processCode(child)) {
|
||||||
const buffer = await stdout;
|
const buffer = await stdio;
|
||||||
if (!process.stdout.write(buffer)) {
|
if (!process.stdout.write(buffer)) {
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
process.stdout.on('error', reject);
|
process.stdout.on('error', reject);
|
||||||
|
|
|
@ -2,6 +2,7 @@ import {mkdir} from 'fs/promises';
|
||||||
import {createServer} from 'net';
|
import {createServer} from 'net';
|
||||||
import {tmpdir} from 'os';
|
import {tmpdir} from 'os';
|
||||||
import {dirname, join} from 'path';
|
import {dirname, join} from 'path';
|
||||||
|
import {PassThrough} from 'stream';
|
||||||
|
|
||||||
import {id} from '@flecks/core/build/testing';
|
import {id} from '@flecks/core/build/testing';
|
||||||
import {
|
import {
|
||||||
|
@ -14,6 +15,7 @@ import {createApplication} from './create-application';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
FLECKS_CORE_ROOT = process.cwd(),
|
FLECKS_CORE_ROOT = process.cwd(),
|
||||||
|
TERM,
|
||||||
} = process.env;
|
} = process.env;
|
||||||
|
|
||||||
class SocketWrapper {
|
class SocketWrapper {
|
||||||
|
@ -135,10 +137,12 @@ export async function startServer({
|
||||||
stdio: 'pipe',
|
stdio: 'pipe',
|
||||||
...opts,
|
...opts,
|
||||||
env: {
|
env: {
|
||||||
|
DEBUG_COLORS: 'dumb' !== TERM,
|
||||||
FLECKS_ENV__flecks_server__stats: '{"preset": "none"}',
|
FLECKS_ENV__flecks_server__stats: '{"preset": "none"}',
|
||||||
FLECKS_ENV__flecks_server__start: true,
|
FLECKS_ENV__flecks_server__start: true,
|
||||||
FLECKS_CORE_ROOT: path,
|
FLECKS_CORE_ROOT: path,
|
||||||
FLECKS_SERVER_TEST_SOCKET: socketPath,
|
FLECKS_SERVER_TEST_SOCKET: socketPath,
|
||||||
|
FORCE_COLOR: 'dumb' !== TERM,
|
||||||
NODE_ENV: 'test',
|
NODE_ENV: 'test',
|
||||||
NODE_PATH: join(FLECKS_CORE_ROOT, '..', '..', 'node_modules'),
|
NODE_PATH: join(FLECKS_CORE_ROOT, '..', '..', 'node_modules'),
|
||||||
...opts.env,
|
...opts.env,
|
||||||
|
@ -149,10 +153,10 @@ export async function startServer({
|
||||||
socketServer.close();
|
socketServer.close();
|
||||||
});
|
});
|
||||||
if (failOnErrorCode) {
|
if (failOnErrorCode) {
|
||||||
const stderr = pipesink(server.stderr);
|
const stdio = pipesink(server.stderr.pipe(server.stdout.pipe(new PassThrough())));
|
||||||
server.on('exit', async (code) => {
|
server.on('exit', async (code) => {
|
||||||
if (!server.done && 0 !== code) {
|
if (!server.done && 0 !== code) {
|
||||||
const buffer = await stderr;
|
const buffer = await stdio;
|
||||||
if (!process.stderr.write(buffer)) {
|
if (!process.stderr.write(buffer)) {
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
process.stderr.on('error', reject);
|
process.stderr.on('error', reject);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user