Skip to content
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
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ module.exports = class ServerlessPluginReducer {
const modulePathsSet = new Set(modulePaths);
await Promise.all(
normalizedIncludeModulePaths.map(includeModulePath => {
if (!includeModulePath.endsWith(".js")) return null;
if (!includeModulePath.endsWith(".js")) {
modulePathsSet.add(includeModulePath);
return null;
}
return getDependencies(servicePath, resolve(servicePath, includeModulePath), {
...options,
ServerlessError
Expand Down
27 changes: 27 additions & 0 deletions test/index/success.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,32 @@ test("Serverless Plugin Reducer: Success", t => {
}
);
});

t.test("Supports include with another type of files", t => {
packagePluginMock.getIncludes = () => ["some-lambda/some-extra-file"];
const onFinally = () => (packagePluginMock.getIncludes = () => []);
packagePluginMock
.resolveFilePathsFunction("some-lambda")
.then(result => {
t.deepEqual(
result.sort(),
[
"node_modules/some-dep/entry.js", "node_modules/some-dep/other.js",
"node_modules/some-dep/package.json", "some-lambda/foo.js",
"some-lambda/index.js", "some-lambda/some-extra-file"
].map(ensureOsSeparators)
);
})
.then(
() => {
onFinally();
t.end();
},
error => {
onFinally();
throw error;
}
);
});
t.end();
});