FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add a newline before printing the result string · forkkit/docker-lambda@cf93693 · GitHub

Commit cf93693

Browse files
committed
Add a newline before printing the result string
This ensures we always have a delimeter between any stdout the user's function may have emitted, and the JSON result string
1 parent 814e04e commit cf93693

8 files changed

Lines changed: 11 additions & 6 deletions

File tree

13 Bytes
Binary file not shown.

‎java8/run/lambda-runtime-mock/src/main/java/lambdainternal/LambdaRuntime.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public static void reportDone(final String invokeid, final byte[] result, final
127127
"Max Memory Used: " + maxMemory + " MB",
128128
""));
129129
if (result != null) {
130-
System.out.println(new String(result, 0, resultLength));
130+
System.out.println("\n" + new String(result, 0, resultLength));
131131
}
132132
}
133133

‎nodejs/run/awslambda-mock.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function systemErr(str) {
2626
}
2727

2828
function handleResult(resultStr, cb) {
29-
if (!process.stdout.write(resultStr)) {
29+
if (!process.stdout.write('\n' + resultStr + '\n')) {
3030
process.stdout.once('drain', cb)
3131
} else {
3232
process.nextTick(cb)

‎nodejs4.3/run/awslambda-mock.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function systemErr(str) {
2626
}
2727

2828
function handleResult(resultStr, cb) {
29-
if (!process.stdout.write(resultStr)) {
29+
if (!process.stdout.write('\n' + resultStr + '\n')) {
3030
process.stdout.once('drain', cb)
3131
} else {
3232
process.nextTick(cb)

‎nodejs6.10/run/awslambda-mock.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function systemErr(str) {
2626
}
2727

2828
function handleResult(resultStr, cb) {
29-
if (!process.stdout.write(resultStr)) {
29+
if (!process.stdout.write('\n' + resultStr + '\n')) {
3030
process.stdout.once('drain', cb)
3131
} else {
3232
process.nextTick(cb)

‎python2.7/run/runtime-mock.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def report_done(invokeid, errortype, result):
149149
)
150150
)
151151
if result:
152-
print(result, file=orig_stdout)
152+
print('\n' + result, file=orig_stdout)
153153
sys.exit(1 if _GLOBAL_ERRORED else 0)
154154
else:
155155
return

‎python3.6/run/runtime-mock.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def report_done(invokeid, errortype, result):
149149
)
150150
)
151151
if result:
152-
print(result, file=orig_stdout)
152+
print('\n' + result, file=orig_stdout)
153153
sys.exit(1 if _GLOBAL_ERRORED else 0)
154154
else:
155155
return

‎test.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ resetMock({status: 0, stdout: 'Test\nResult\n{"success":true}'})
8181
result = dockerLambda()
8282
result.should.eql({success: true})
8383

84+
// Should not fail if stdout contains extra newlines
85+
resetMock({status: 0, stdout: 'Test\nResult\n\n{"success":true}\n\n'})
86+
result = dockerLambda()
87+
result.should.eql({success: true})
88+
8489
// Should return undefined if last stdout entry cannot be parsed
8590
resetMock({status: 0, stdout: 'Test\nResult\nsuccess'})
8691
result = dockerLambda()

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL