Skip to content

Commit

Permalink
minor tweak to output styling
Browse files Browse the repository at this point in the history
  • Loading branch information
austencollins committed Aug 14, 2017
2 parents cfd6b21 + b7aa82c commit 09a8d4f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/plugins/emit/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ describe('Emit', () => {
).to.equal(true);
expect(logStub.getCall(0).args[0]).to.equal(
// eslint-disable-next-line max-len
'\u001b[38;5;178m Serverless \u001b[39mEmitted the event userCreated as datatype application/json:\n \u001b[38;5;243m{\u001b[39m\n\u001b[38;5;243m "key": "value"\u001b[39m\n\u001b[38;5;243m }\u001b[39m'
' Serverless Emitted the event userCreated as datatype application/json:\n {\n "key": "value"\n }'
);
});
});
Expand All @@ -163,7 +163,7 @@ describe('Emit', () => {
).to.equal(true);
expect(logStub.getCall(0).args[0]).to.equal(
// eslint-disable-next-line max-len
'\u001b[38;5;178m Serverless \u001b[39mEmitted the event userCreated as datatype text/plain:\n \u001b[38;5;243m"This is a message"\u001b[39m'
' Serverless Emitted the event userCreated as datatype text/plain:\n "This is a message"'
);
});
});
Expand Down
11 changes: 8 additions & 3 deletions lib/plugins/run/utils/getLocalEmulatorFunctionConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,17 @@ function getLocalEmulatorFunctionConfig(functionConfig, providerConfig, serviceP
localEmulatorFunctionConfig.region = providerConfig.region;
localEmulatorFunctionConfig.envVars = envVars;
} else if (provider === 'google') {
const memorySize = Number(functionConfig.memorySize)
|| Number(providerConfig.memorySize)
|| 1024;
localEmulatorFunctionConfig.functionName = functionConfig.name;
// TODO localEmulatorFunctionConfig.eventType = ?
localEmulatorFunctionConfig.project = providerConfig.project;
localEmulatorFunctionConfig.memorySize = memorySize;
localEmulatorFunctionConfig.env = {
REGION: providerConfig.region,
FUNCTION_NAME: functionConfig.name,
MEMORY_SIZE: Number(functionConfig.memorySize)
|| Number(providerConfig.memorySize)
|| 1024,
MEMORY_SIZE: memorySize,
};

localEmulatorFunctionConfig.env = _.merge(localEmulatorFunctionConfig.env,
Expand Down
10 changes: 7 additions & 3 deletions lib/plugins/run/utils/logEventGateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ const getMessage = msg => {
const text = `Event received: ${event.event}${os.EOL}`;
return `${text}${colorDim(prettifyValue(event))}${os.EOL}`;
} else if (parsedMsg.msg === 'Function triggered.') {
// const event = prettifyValue(JSON.parse(parsedMsg.event));
const text = `Function triggered: ${parsedMsg.functionId}${os.EOL}`;
const event = JSON.parse(parsedMsg.event);
const text = `Function triggered: ${parsedMsg.functionId} by event ${event.event}${os.EOL}`;
return `${text}`;
} else if (parsedMsg.msg === 'Function finished.') {
const response = prettifyValue(JSON.parse(parsedMsg.response));
const text = `Function finished: ${parsedMsg.functionId}${os.EOL}${colorDim(response)}${os.EOL}`;
return `${text}`;
} else if (parsedMsg.msg === 'Function not found for HTTP event.') {
const response = prettifyValue(JSON.parse(parsedMsg.event));
const text = `Function not found for HTTP event:${os.EOL}${colorDim(response)}`;
return `${text}`;
} else if (parsedMsg.msg === 'Function invocation failed.') {
const text = `Failed to invoke function ${parsedMsg.functionId}${os.EOL}`;
const errorText = `${spaceLarge}error: ${parsedMsg.error}`;
Expand All @@ -58,7 +62,7 @@ const getMessage = msg => {
}
throw new Error('Could not parse boot message');
} else {
return false;
throw new Error('Could not parse message');
}
};

Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/run/utils/logEventGateway.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('logEventGateway', () => {
})
);
expect(logStub.calledOnce).to.be.equal(true);
const expected = '\u001b[38;5;173m Event Gateway \u001b[39mFunction registered: s1-f1\n';
const expected = ' Event Gateway Function registered: s1-f1\n';
expect(logStub.getCall(0).args[0]).to.be.equal(expected);
});

Expand All @@ -47,7 +47,7 @@ describe('logEventGateway', () => {
);
expect(logStub.calledOnce).to.be.equal(true);
const expected = // eslint-disable-next-line max-len
'\u001b[38;5;173m Event Gateway \u001b[39mEvent received: undefined\n\u001b[38;5;243m {\u001b[39m\n\u001b[38;5;243m "headers": {\u001b[39m\n\u001b[38;5;243m "Accept": [\u001b[39m\n\u001b[38;5;243m "image/webp,image/apng,image/*,*/*;q=0.8"\u001b[39m\n\u001b[38;5;243m ],\u001b[39m\n\u001b[38;5;243m "Accept-Encoding": [\u001b[39m\n\u001b[38;5;243m "gzip, deflate, br"\u001b[39m\n\u001b[38;5;243m ],\u001b[39m\n\u001b[38;5;243m "Accept-Language": [\u001b[39m\n\u001b[38;5;243m "en-US,en;q=0.8"\u001b[39m\n\u001b[38;5;243m ],\u001b[39m\n\u001b[38;5;243m "Cache-Control": [\u001b[39m\n\u001b[38;5;243m "no-cache"\u001b[39m\n\u001b[38;5;243m ],\u001b[39m\n\u001b[38;5;243m "Connection": [\u001b[39m\n\u001b[38;5;243m "keep-alive"\u001b[39m\n\u001b[38;5;243m ],\u001b[39m\n\u001b[38;5;243m "Pragma": [\u001b[39m\n\u001b[38;5;243m "no-cache"\u001b[39m\n\u001b[38;5;243m ],\u001b[39m\n\u001b[38;5;243m "Referer": [\u001b[39m\n\u001b[38;5;243m "http://localhost:4000/"\u001b[39m\n\u001b[38;5;243m ],\u001b[39m\n\u001b[38;5;243m "User-Agent": [\u001b[39m\n\u001b[38;5;243m "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"\u001b[39m\n\u001b[38;5;243m ]\u001b[39m\n\u001b[38;5;243m },\u001b[39m\n\u001b[38;5;243m "query": {},\u001b[39m\n\u001b[38;5;243m "body": ""\u001b[39m\n\u001b[38;5;243m }\u001b[39m\n';
' Event Gateway Event received: undefined\n {\n "headers": {\n "Accept": [\n "image/webp,image/apng,image/*,*/*;q=0.8"\n ],\n "Accept-Encoding": [\n "gzip, deflate, br"\n ],\n "Accept-Language": [\n "en-US,en;q=0.8"\n ],\n "Cache-Control": [\n "no-cache"\n ],\n "Connection": [\n "keep-alive"\n ],\n "Pragma": [\n "no-cache"\n ],\n "Referer": [\n "http://localhost:4000/"\n ],\n "User-Agent": [\n "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"\n ]\n },\n "query": {},\n "body": ""\n }\n';
expect(logStub.getCall(0).args[0]).to.be.equal(expected);
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"sls": "./bin/serverless"
},
"scripts": {
"test": "env FORCE_COLOR=1 istanbul cover -x '**/*.test.js' node_modules/mocha/bin/_mocha '!(node_modules)/**/*.test.js' -- --require=sinon-bluebird -R spec --recursive",
"test": "env FORCE_COLOR=0 istanbul cover -x '**/*.test.js' node_modules/mocha/bin/_mocha '!(node_modules)/**/*.test.js' -- --require=sinon-bluebird -R spec --recursive",
"lint": "eslint . --cache",
"docs": "node scripts/generate-readme.js",
"simple-integration-test": "jest --maxWorkers=5 simple-suite",
Expand Down

0 comments on commit 09a8d4f

Please sign in to comment.