Skip to content

Commit 6a4634a

Browse files
committedJan 5, 2019
Adds the ability to specify an exclideFiles glob
This permits you to tell serverless to ignore files that have similar names to the route handlers. So ignore index.test.js or index.ts. This fixes serverless-heaven#433 and serverless-heaven#405 It makes life better for lots of folks :-)
1 parent ffc70bc commit 6a4634a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed
 

‎lib/Configuration.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
const _ = require('lodash');
77

8-
/**
8+
/**
99
* Plugin defaults
1010
*/
1111
const DefaultConfig = {
@@ -50,6 +50,10 @@ class Configuration {
5050
return this._config.includeModules;
5151
}
5252

53+
get excludeFiles() {
54+
return this._config.excludeFiles;
55+
}
56+
5357
get packager() {
5458
return this._config.packager;
5559
}

‎lib/validate.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ module.exports = {
3333
const getEntryExtension = fileName => {
3434
const files = glob.sync(`${fileName}.*`, {
3535
cwd: this.serverless.config.servicePath,
36-
nodir: true
36+
nodir: true,
37+
ignore: this.configuration.excludeFiles ? this.configuration.excludeFiles : undefined
3738
});
3839

40+
this.serverless.cli.log(files);
41+
3942
if (_.isEmpty(files)) {
4043
// If we cannot find any handler we should terminate with an error
4144
throw new this.serverless.classes.Error(`No matching handler found for '${fileName}' in '${this.serverless.config.servicePath}'. Check your service definition.`);
@@ -117,7 +120,7 @@ module.exports = {
117120
return BbPromise.reject(err);
118121
}
119122
}
120-
123+
121124
// Intermediate function to handle async webpack config
122125
const processConfig = _config => {
123126
this.webpackConfig = _config;
@@ -220,7 +223,7 @@ module.exports = {
220223

221224
return BbPromise.resolve();
222225
};
223-
226+
224227
// Webpack config can be a Promise, If it's a Promise wait for resolved config object.
225228
if (this.webpackConfig && _.isFunction(this.webpackConfig.then)) {
226229
return BbPromise.resolve(this.webpackConfig.then(config => processConfig(config)));

0 commit comments

Comments
 (0)