Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

* Fixes Issues #29, #51. #34: Allow patterns #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,16 @@ class PackageRubyBundlePlugin {
puts JSON.generate(details.sort_by{|x| x[:name]})
`

let whitelist_provider
if (this.serverless.service.package.hasOwnProperty('patterns')){
whitelist_provider = this.serverless.service.package.patterns
}else if (this.serverless.service.package.hasOwnProperty('include')){
whitelist_provider = this.serverless.service.package.include
}

this.serverless.service.package.excludeDevDependencies = false; // only relevant to nodejs
this.serverless.service.package.exclude = ["**"]; // force whitelist
this.serverless.service.package.include.push("vendor/bundle/bundler/**"); // bundler standalone files
whitelist_provider.push("vendor/bundle/bundler/**"); // bundler standalone files

const gemFilePath = path.join(this.serverless.config.servicePath, "Gemfile");
const bundleEnv = Object.assign({
Expand All @@ -104,19 +111,19 @@ class PackageRubyBundlePlugin {
}

gems.forEach((gem) =>{
this.serverless.service.package.include.push(`${gemRoot}${gem.path}/**`);
whitelist_provider.push(`${gemRoot}${gem.path}/**`);
if (gem.extensions){
this.serverless.service.package.include.push(`${extensionDir}/${gem.name}/**`);
whitelist_provider.push(`${extensionDir}/${gem.name}/**`);
}

// includes that start with a ! are treated as excludes when evaluating,
// but are ordered along with the includes. If these patterns were
// specified as excludes, they would be evaluated first, and then the
// includes on the gem paths would bring them back.
this.serverless.service.package.include.push(`!${gemRoot}${gem.path}/.git/**`);
whitelist_provider.push(`!${gemRoot}${gem.path}/.git/**`);
if (excludeGemTests) {
this.serverless.service.package.include.push(`!${gemRoot}${gem.path}/test/**`);
this.serverless.service.package.include.push(`!${gemRoot}${gem.path}/spec/**`);
whitelist_provider.push(`!${gemRoot}${gem.path}/test/**`);
whitelist_provider.push(`!${gemRoot}${gem.path}/spec/**`);
}
});
}
Expand Down