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

fix excludeRegex by actually excluding files #777

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
14 changes: 9 additions & 5 deletions lib/packageModules.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,19 @@ function setArtifactPath(funcName, func, artifactPath) {

function zip(directory, name) {
// Check that files exist to be zipped
let files = glob.sync('**', {
const globFiles = glob.sync('**', {
cwd: directory,
dot: true,
silent: true,
follow: true
follow: true,
nodir: true
});

if (this.configuration.excludeRegex) {
files = _.filter(files, f => f.match(this.configuration.excludeRegex) === null);
const files = this.configuration.excludeRegex
? _.filter(globFiles, f => f.match(this.configuration.excludeRegex) === null)
: globFiles;
if (files.length < globFiles.length && this.options.verbose) {
this.serverless.cli.log(`Excluded ${globFiles.length - files.length} file(s) based on excludeRegex`);
}

if (_.isEmpty(files)) {
Expand All @@ -49,7 +53,7 @@ function zip(directory, name) {
this.serverless.utils.writeFileDir(artifactFilePath);

const cwd = directory;
const source = '*';
const source = files;
const destination = path.relative(cwd, artifactFilePath);
const zipArgs = {
source,
Expand Down
2 changes: 1 addition & 1 deletion lib/wpwatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ module.exports = {
}

process.env.SLS_DEBUG &&
this.serverless.cli.log(`Webpack watch invoke: HASH NEW=${stats.hash} CUR=${lastHash}`);
this.serverless.cli.log(`Webpack watch invoke: HASH NEW=${stats && stats.hash} CUR=${lastHash}`);

// If the file hash did not change there were no effective code changes detected
// (comment changes do not change the compile hash and do not account for a rebuild!)
Expand Down