Skip to content

Commit 102f221

Browse files
committed
handle unknown statement for function module
1 parent e76d421 commit 102f221

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

open-abap/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

template/open-abap/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const express = require('express')
44
const app = express()
5-
const handler = require('./build/handler'); // this is the JS source which has been transpoled from ABAP
5+
const handler = require('./build/handler'); // this is the JS source which has been transpiled from ABAP
66
const bodyParser = require('body-parser')
77

88
if (process.env.RAW_BODY === 'true') {

template/open-abap/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "openfaas-open-abap",
33
"version": "1.0.0",
4-
"description": "Template for ABAP source based functinos",
4+
"description": "Template for ABAP source based functions",
55
"main": "index.js",
66
"scripts": {
77
"build": "npm run build:transpile-abap",

template/open-abap/scripts/build.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ const abapToJs = async function (abapFile) {
3838
.join('\n')
3939
+ abapSourceString
4040

41-
let transpiledSource = transpiler.run(abapSourceString)
41+
let transpiledSource = transpiler.run(abapSourceString
42+
.replace('FUNCTION HANDLER.', '') // function not supported, we just mock it
43+
.replace('ENDFUNCTION.', '')
44+
)
4245

4346
// inject variable initialization
4447
if (abapSignatureLines && abapSignatureLines.length) {
@@ -55,8 +58,7 @@ const abapToJs = async function (abapFile) {
5558

5659
return FUNCTION_SETUP
5760
+ transpiledSource
58-
.replace('todo, statement: FunctionModule', '')
59-
.replace('todo, statement: EndFunction', 'return {result: result.get(), code: code.get() || 200}\n}')
61+
+ 'return { result: output.get(), code: code.get() || 200 }\n}'
6062
}
6163

6264
let abapSourceString = (await fs.readFile(abapFile)).toString()

template/open-abap/test.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,13 @@ cd build
1515
cd $(ls)
1616
npm i
1717

18-
cp -R ../../test .
18+
if [ -z $1 ]; then
19+
cp -R ../../test . # default (locally): copy tests from non-shrinkwrapped folder
20+
elif [ $1 -eq '.' ]; then
21+
# no need to copy anything
22+
echo 'Executing tests from local directory'
23+
else
24+
cp -R $1 .
25+
fi
26+
1927
npm test

0 commit comments

Comments
 (0)