Repository: brefphp/bref (language: php)

Issue:
Handle patterns instead of exclude in serverless.yml when using separate vendor option
**Description:**

When using the separate vendor option, the vendor directory is added to the package.exclude array in the serverless.yml, if it's not there yet. package.exclude is deprecated and it is now recommended to use package.patterns. Not defining the package.exclude key will result in an error.

Deprecation: https://www.serverless.com/framework/docs/deprecations/#NEW_PACKAGE_PATTERNS

This bug can easily be fixed, I will open a pull request shortly.

**How to reproduce:**

```
custom:
    bref:
        separateVendor: true

package:
    patterns:
        - '!node_modules/**'
```
Handle patterns instead of exclude in serverless.yml when using separate vendor option
**Description:**

When using the separate vendor option, the vendor directory is added to the package.exclude array in the serverless.yml, if it's not there yet. package.exclude is deprecated and it is now recommended to use package.patterns. Not defining the package.exclude key will result in an error.

Deprecation: https://www.serverless.com/framework/docs/deprecations/#NEW_PACKAGE_PATTERNS

This bug can easily be fixed, I will open a pull request shortly.

**How to reproduce:**

```
custom:
    bref:
        separateVendor: true

package:
    patterns:
        - '!node_modules/**'
```


Discussion / hints:

Fix patch:
diff --git a/index.js b/index.js
index 4585658c6..b22866874 100644
--- a/index.js
+++ b/index.js
@@ -103,8 +103,12 @@ class ServerlessPlugin {
         // we will add it here as we do not want the vendor folder in our
         // lambda archive file.
         let excludes = this.serverless.service.package.exclude;
-        if(excludes.indexOf('vendor/**') === -1) {
-            excludes[excludes.length] = 'vendor/**';
+        if(excludes && excludes.indexOf('vendor/**') === -1) {
+            excludes.push('vendor/**');
+        }
+        let patterns = this.serverless.service.package.patterns;
+        if(patterns && patterns.indexOf('!vendor/**') === -1) {
+            patterns.push('!vendor/**');
         }
 
         // This defines the access rights for Lambda, so it can download the


Test patch: