mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
fix(Packaging): Fix resolution of files with '.' In their names (#8130)
This commit is contained in:
parent
e131f2661d
commit
c620af3cd6
@ -4,7 +4,7 @@ const BbPromise = require('bluebird');
|
||||
const path = require('path');
|
||||
const globby = require('globby');
|
||||
const _ = require('lodash');
|
||||
const nanomatch = require('nanomatch');
|
||||
const micromatch = require('micromatch');
|
||||
const serverlessConfigFileUtils = require('../../../../lib/utils/getServerlessConfigFile');
|
||||
|
||||
module.exports = {
|
||||
@ -256,14 +256,14 @@ module.exports = {
|
||||
}).then(allFilePaths => {
|
||||
const filePathStates = allFilePaths.reduce((p, c) => Object.assign(p, { [c]: true }), {});
|
||||
patterns
|
||||
// nanomatch only does / style path delimiters, so convert them if on windows
|
||||
// micromatch only does / style path delimiters, so convert them if on windows
|
||||
.map(p => {
|
||||
return process.platform === 'win32' ? p.replace(/\\/g, '/') : p;
|
||||
})
|
||||
.forEach(p => {
|
||||
const exclude = p.startsWith('!');
|
||||
const pattern = exclude ? p.slice(1) : p;
|
||||
nanomatch(allFilePaths, [pattern], { dot: true }).forEach(key => {
|
||||
micromatch(allFilePaths, [pattern], { dot: true }).forEach(key => {
|
||||
filePathStates[key] = !exclude;
|
||||
});
|
||||
});
|
||||
|
||||
@ -612,12 +612,14 @@ 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', () => {
|
||||
@ -651,7 +653,7 @@ describe('#packageService()', () => {
|
||||
exclude: [],
|
||||
include: [`!${utilsFile}`],
|
||||
};
|
||||
const expected = [handlerFile];
|
||||
const expected = [dotsFile, handlerFile];
|
||||
serverless.config.servicePath = servicePath;
|
||||
|
||||
return expect(
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
"filesize": "^3.6.1",
|
||||
"fs-extra": "^8.1.0",
|
||||
"get-stdin": "^6.0.0",
|
||||
"globby": "^9.2.0",
|
||||
"globby": "^11.0.1",
|
||||
"graceful-fs": "^4.2.4",
|
||||
"https-proxy-agent": "^5.0.0",
|
||||
"is-docker": "^1.1.0",
|
||||
@ -57,8 +57,8 @@
|
||||
"jwt-decode": "^2.2.0",
|
||||
"lodash": "^4.17.20",
|
||||
"memoizee": "^0.4.14",
|
||||
"micromatch": "^4.0.2",
|
||||
"mkdirp": "^0.5.4",
|
||||
"nanomatch": "^1.2.13",
|
||||
"ncjsm": "^4.1.0",
|
||||
"node-fetch": "^2.6.1",
|
||||
"object-hash": "^2.0.3",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user