This repository was archived by the owner on Dec 9, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,11 @@ class BaseRuntime {
5151 }
5252
5353 convertHandlerToPath ( functionHandler ) {
54- return functionHandler . replace ( / \. .* $ / , this . extension )
54+ const lastDot = functionHandler . lastIndexOf ( '.' ) ;
55+ if ( lastDot === - 1 ) {
56+ return functionHandler ;
57+ }
58+ return functionHandler . substring ( 0 , lastDot ) + this . extension ;
5559 }
5660
5761 generateActionPackage ( functionObject ) {
Original file line number Diff line number Diff line change @@ -7,6 +7,29 @@ require('chai').use(chaiAsPromised);
77
88const sinon = require ( 'sinon' ) ;
99const OpenWhiskCompileFunctions = require ( '../index' ) ;
10+ const BaseRuntime = require ( '../runtimes/base.js' ) ;
11+
12+ describe ( 'BaseRuntime' , ( ) => {
13+ describe ( '#convertHandlerToPath' , ( ) => {
14+ const base = new BaseRuntime ( ) ;
15+ base . extension = '.js' ;
16+
17+ it ( 'should extract the path for a given file handler' , ( ) => {
18+ const result = base . convertHandlerToPath ( 'index.main' ) ;
19+ expect ( result ) . to . equal ( 'index.js' ) ;
20+ } ) ;
21+
22+ it ( 'should return the input for a given file handler without exported function' , ( ) => {
23+ const result = base . convertHandlerToPath ( 'index' ) ;
24+ expect ( result ) . to . equal ( 'index' ) ;
25+ } ) ;
26+
27+ it ( 'should extract the path for a given path handler' , ( ) => {
28+ const result = base . convertHandlerToPath ( '[email protected] /index.main' ) ; 29+ expect ( result ) . to . equal ( '[email protected] /index.js' ) ; 30+ } ) ;
31+ } ) ;
32+ } ) ;
1033
1134describe ( 'OpenWhiskCompileFunctions' , ( ) => {
1235 let serverless ;
You can’t perform that action at this time.
0 commit comments