mirror of
https://github.com/serverless/serverless.git
synced 2026-02-01 16:07:28 +00:00
Merge pull request #5808 from serverless/sls-5745
Replace \ with / in paths on windows before passing to nanomatch
This commit is contained in:
commit
d21557a430
@ -197,14 +197,17 @@ module.exports = {
|
||||
nodir: true,
|
||||
}).then(allFilePaths => {
|
||||
const filePathStates = allFilePaths.reduce((p, c) => Object.assign(p, { [c]: true }), {});
|
||||
patterns.forEach(p => {
|
||||
const exclude = p.startsWith('!');
|
||||
const pattern = exclude ? p.slice(1) : p;
|
||||
nanomatch(allFilePaths, [pattern], { dot: true })
|
||||
.forEach(key => {
|
||||
filePathStates[key] = !exclude;
|
||||
});
|
||||
});
|
||||
patterns
|
||||
// nanomatch only does / style path delimiters, so convert them if on windows
|
||||
.map(p => (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 => {
|
||||
filePathStates[key] = !exclude;
|
||||
});
|
||||
});
|
||||
const filePaths = _.toPairs(filePathStates).filter(r => r[1] === true).map(r => r[0]);
|
||||
if (filePaths.length !== 0) return filePaths;
|
||||
throw new this.serverless.classes.Error('No file matches include / exclude patterns');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user