Skip to content

Commit

Permalink
chore: undo stupid cluster stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
XVincentX committed May 25, 2019
1 parent 750c11e commit 8e0fcaf
Showing 1 changed file with 17 additions and 28 deletions.
45 changes: 17 additions & 28 deletions packages/cli/src/commands/mock.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Command } from '@oclif/command';
import * as cluster from 'cluster';
import * as signale from 'signale';
import { ARGS, FLAGS } from '../const/options';
import { createServer } from '../util/createServer';
Expand All @@ -17,38 +16,28 @@ export default class Server extends Command {
args: { spec },
} = this.parse(Server);

if (cluster.isMaster) {
signaleInteractiveInstance.await('Starting Prism…');
signaleInteractiveInstance.await('Starting Prism…');

if (true || dynamic) {
signale.star('Dynamic example generation enabled.');
}

cluster.setupMaster({
silent: true,
});

const worker = cluster.fork();
if (true || dynamic) {
signale.star('Dynamic example generation enabled.');
}

if (worker.process.stdout) worker.process.stdout.pipe(process.stdout);
} else {
const server = createServer(spec, { mock: { dynamic: true || dynamic } });
try {
const address = await server.listen(port);
const server = createServer(spec, { mock: { dynamic: true || dynamic } });
try {
const address = await server.listen(port);

if (server.prism.resources.length === 0) {
signaleInteractiveInstance.fatal('No operations found in the current file.');
this.exit(1);
}
if (server.prism.resources.length === 0) {
signaleInteractiveInstance.fatal('No operations found in the current file.');
this.exit(1);
}

signaleInteractiveInstance.success(`Prism is listening on ${address}`);
signaleInteractiveInstance.success(`Prism is listening on ${address}`);

server.prism.resources.forEach(resource => {
signale.note(`${resource.method.toUpperCase().padEnd(10)} ${address}${resource.path}`);
});
} catch (e) {
signaleInteractiveInstance.fatal(e.message);
}
server.prism.resources.forEach(resource => {
signale.note(`${resource.method.toUpperCase().padEnd(10)} ${address}${resource.path}`);
});
} catch (e) {
signaleInteractiveInstance.fatal(e.message);
}
}
}

0 comments on commit 8e0fcaf

Please sign in to comment.