Skip to content

Commit

Permalink
Fix packaging with files that contain dots as part of the name
Browse files Browse the repository at this point in the history
This ports a fix introduced in serverless-components: serverless-components/aws-lambda#26 but given some changes in the test,
it probably needs to be flagged as a breaking change.

Fixes #8125
  • Loading branch information
crash7 committed Aug 26, 2020
1 parent 45080ed commit 9a6df26
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/plugins/package/lib/packageService.js
Expand Up @@ -247,7 +247,7 @@ module.exports = {
// NOTE: please keep this order of concatenating the include params
// rather than doing it the other way round!
// see https://github.com/serverless/serverless/pull/5825 for more information
return globby(['**'].concat(params.include), {
return globby(['**/*'].concat(params.include), {
cwd: path.join(this.serverless.config.servicePath, prefix || ''),
dot: true,
silent: true,
Expand Down
8 changes: 5 additions & 3 deletions lib/plugins/package/lib/packageService.test.js
Expand Up @@ -612,17 +612,19 @@ describe('#packageService()', () => {
// independent file paths
const handlerFile = 'src/function/handler.js';
const utilsFile = 'src/utils/utils.js';
const dotsFile = 'src/dots/[...file].js';
let servicePath;

beforeEach(() => {
servicePath = createTmpDir();
fse.ensureFileSync(path.join(servicePath, handlerFile));
fse.ensureFileSync(path.join(servicePath, utilsFile));
fse.ensureFileSync(path.join(servicePath, dotsFile));
});

it('should exclude all and include function/handler.js', () => {
const params = {
exclude: ['**'],
exclude: ['**/*'],
include: [handlerFile],
};
serverless.config.servicePath = servicePath;
Expand All @@ -642,7 +644,7 @@ describe('#packageService()', () => {
return expect(
packagePlugin.resolveFilePathsFromPatterns(params)
).to.be.fulfilled.then(actual =>
expect(actual.sort()).to.deep.equal([handlerFile, utilsFile].sort())
expect(actual.sort()).to.deep.equal([dotsFile, handlerFile, utilsFile].sort())
);
});

Expand All @@ -651,7 +653,7 @@ describe('#packageService()', () => {
exclude: [],
include: [`!${utilsFile}`],
};
const expected = [handlerFile];
const expected = [dotsFile, handlerFile];
serverless.config.servicePath = servicePath;

return expect(
Expand Down

0 comments on commit 9a6df26

Please sign in to comment.