mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-18 13:35:08 +00:00
make stdout etc available via api
This commit is contained in:
@@ -9,7 +9,6 @@
|
|||||||
"files": [
|
"files": [
|
||||||
"*.js",
|
"*.js",
|
||||||
"*.ts.js",
|
"*.ts.js",
|
||||||
"api",
|
|
||||||
"runtime",
|
"runtime",
|
||||||
"webpack",
|
"webpack",
|
||||||
"sapper",
|
"sapper",
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import prettyMs from 'pretty-ms';
|
|||||||
import { locations } from '../config';
|
import { locations } from '../config';
|
||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
import { create_routes, create_main_manifests, create_compilers, create_serviceworker_manifest } from '../core';
|
import { create_routes, create_main_manifests, create_compilers, create_serviceworker_manifest } from '../core';
|
||||||
import * as events from '../interfaces';
|
import * as events from './interfaces';
|
||||||
|
|
||||||
export function dev(opts) {
|
export function dev(opts) {
|
||||||
return new Watcher(opts);
|
return new Watcher(opts);
|
||||||
@@ -143,6 +143,10 @@ class Watcher extends EventEmitter {
|
|||||||
fs.writeFileSync(path.join(dest, 'server_info.json'), JSON.stringify(info, null, ' '));
|
fs.writeFileSync(path.join(dest, 'server_info.json'), JSON.stringify(info, null, ' '));
|
||||||
|
|
||||||
this.deferreds.client.promise.then(() => {
|
this.deferreds.client.promise.then(() => {
|
||||||
|
this.dev_server.send({
|
||||||
|
status: 'completed'
|
||||||
|
});
|
||||||
|
|
||||||
const restart = () => {
|
const restart = () => {
|
||||||
ports.wait(this.port).then(this.deferreds.server.fulfil);
|
ports.wait(this.port).then(this.deferreds.server.fulfil);
|
||||||
};
|
};
|
||||||
@@ -158,7 +162,13 @@ class Watcher extends EventEmitter {
|
|||||||
cwd: process.cwd(),
|
cwd: process.cwd(),
|
||||||
env: Object.assign({
|
env: Object.assign({
|
||||||
PORT: this.port
|
PORT: this.port
|
||||||
}, process.env)
|
}, process.env),
|
||||||
|
stdio: ['ipc']
|
||||||
|
});
|
||||||
|
|
||||||
|
this.emit('ready', <events.ReadyEvent>{
|
||||||
|
port: this.port,
|
||||||
|
process: this.proc
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -186,16 +196,6 @@ class Watcher extends EventEmitter {
|
|||||||
|
|
||||||
const client_files = info.assets.map((chunk: { name: string }) => `client/${chunk.name}`);
|
const client_files = info.assets.map((chunk: { name: string }) => `client/${chunk.name}`);
|
||||||
|
|
||||||
this.deferreds.server.promise.then(() => {
|
|
||||||
this.dev_server.send({
|
|
||||||
status: 'completed'
|
|
||||||
});
|
|
||||||
|
|
||||||
this.emit('ready', <events.ReadyEvent>{
|
|
||||||
port: this.port
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
create_serviceworker_manifest({
|
create_serviceworker_manifest({
|
||||||
routes: create_routes(),
|
routes: create_routes(),
|
||||||
client_files
|
client_files
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
|
import * as child_process from 'child_process';
|
||||||
|
|
||||||
export type ReadyEvent = {
|
export type ReadyEvent = {
|
||||||
port: number;
|
port: number;
|
||||||
|
process: child_process.ChildProcess;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ErrorEvent = {
|
export type ErrorEvent = {
|
||||||
|
|||||||
Reference in New Issue
Block a user