Skip to content

Commit

Permalink
stop ignoring CONSOLE_LOG events
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott committed Oct 16, 2020
1 parent 05fa08b commit 652bd98
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion plugins/plugin-run-script/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function runScriptPlugin(_, {cmd, watch, output}) {
function dataListener(chunk) {
let stdOutput = chunk.toString();
if (output === 'stream') {
log('CONSOLE_INFO', {id: cmdProgram, msg: stdOutput});
log('CONSOLE_INFO', {msg: stdOutput});
return;
}
if (stdOutput.includes('\u001bc') || stdOutput.includes('\x1Bc')) {
Expand Down
4 changes: 2 additions & 2 deletions plugins/plugin-run-script/test/plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ describe.skip('plugin-run-script', () => {
execaResult.stdout.emit('data', Buffer.from('STDOUT_TEST_MESSAGE'));
execaResult.stderr.emit('data', Buffer.from('STDERR_TEST_MESSAGE'));
expect(logFn.mock.calls).toEqual([
['CONSOLE_INFO', {id: 'CMD', msg: 'STDOUT_TEST_MESSAGE'}],
['CONSOLE_INFO', {id: 'CMD', msg: 'STDERR_TEST_MESSAGE'}],
['CONSOLE_INFO', {msg: 'STDOUT_TEST_MESSAGE'}],
['CONSOLE_INFO', {msg: 'STDERR_TEST_MESSAGE'}],
]);
});
test('handles command output in "dashboard" mode', async () => {
Expand Down
4 changes: 2 additions & 2 deletions snowpack/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ export async function command(commandOptions: CommandOptions) {
isHmrEnabled: getIsHmrEnabled(config),
// @ts-ignore: internal API only
log: (msg, data: {msg: string} = {}) => {
if (msg === 'WORKER_MSG') {
logger.info(`[${runPlugin.name}] ${data.msg.trim()}`);
if (msg === 'CONSOLE_INFO' || msg === 'WORKER_MSG') {
logger.info(data.msg.trim(), {name: runPlugin.name});
}
},
})
Expand Down
6 changes: 5 additions & 1 deletion snowpack/src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,11 @@ export async function startServer(commandOptions: CommandOptions) {
isHmrEnabled: isHmr,
// @ts-ignore: internal API only
log: (msg, data) => {
messageBus.emit(msg, {...data, id: runPlugin.name});
if (msg === 'CONSOLE_INFO') {
logger.info(data.msg, {name: runPlugin.name});
} else {
messageBus.emit(msg, {...data, id: runPlugin.name});
}
},
})
.then(() => {
Expand Down

1 comment on commit 652bd98

@vercel
Copy link

@vercel vercel bot commented on 652bd98 Oct 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.