Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion compile/functions/runtimes/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ class BaseRuntime {
}

convertHandlerToPath(functionHandler) {
return functionHandler.replace(/\..*$/, this.extension)
const lastDot = functionHandler.lastIndexOf('.');
if (lastDot === -1) {
return functionHandler;
}
return functionHandler.substring(0, lastDot) + this.extension;
}

generateActionPackage(functionObject) {
Expand Down
23 changes: 23 additions & 0 deletions compile/functions/tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@ require('chai').use(chaiAsPromised);

const sinon = require('sinon');
const OpenWhiskCompileFunctions = require('../index');
const BaseRuntime = require('../runtimes/base.js');

describe('BaseRuntime', () => {
describe('#convertHandlerToPath', () => {
const base = new BaseRuntime();
base.extension = '.js';

it('should extract the path for a given file handler', () => {
const result = base.convertHandlerToPath('index.main');
expect(result).to.equal('index.js');
});

it('should return the input for a given file handler without exported function', () => {
const result = base.convertHandlerToPath('index');
expect(result).to.equal('index');
});

it('should extract the path for a given path handler', () => {
const result = base.convertHandlerToPath('myFunction@0.1.0/index.main');
expect(result).to.equal('myFunction@0.1.0/index.js');
});
});
});

describe('OpenWhiskCompileFunctions', () => {
let serverless;
Expand Down