Skip to content

Commit e60ed9e

Browse files
authored
fix: Fix package inclusion to accept any file's type (#8)
1 parent aea8073 commit e60ed9e

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ module.exports = class ServerlessPluginReducer {
6161
const modulePathsSet = new Set(modulePaths);
6262
await Promise.all(
6363
normalizedIncludeModulePaths.map(includeModulePath => {
64-
if (!includeModulePath.endsWith(".js")) return null;
64+
if (!includeModulePath.endsWith(".js")) {
65+
modulePathsSet.add(includeModulePath);
66+
return null;
67+
}
6568
return getDependencies(servicePath, resolve(servicePath, includeModulePath), {
6669
...options,
6770
ServerlessError

test/index/success.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,32 @@ test("Serverless Plugin Reducer: Success", t => {
7979
}
8080
);
8181
});
82+
83+
t.test("Supports include with another type of files", t => {
84+
packagePluginMock.getIncludes = () => ["some-lambda/some-extra-file"];
85+
const onFinally = () => (packagePluginMock.getIncludes = () => []);
86+
packagePluginMock
87+
.resolveFilePathsFunction("some-lambda")
88+
.then(result => {
89+
t.deepEqual(
90+
result.sort(),
91+
[
92+
"node_modules/some-dep/entry.js", "node_modules/some-dep/other.js",
93+
"node_modules/some-dep/package.json", "some-lambda/foo.js",
94+
"some-lambda/index.js", "some-lambda/some-extra-file"
95+
].map(ensureOsSeparators)
96+
);
97+
})
98+
.then(
99+
() => {
100+
onFinally();
101+
t.end();
102+
},
103+
error => {
104+
onFinally();
105+
throw error;
106+
}
107+
);
108+
});
82109
t.end();
83110
});

0 commit comments

Comments
 (0)