Raise error if no file matches before zipping

This commit is contained in:
Alex Casalboni 2017-06-05 17:36:14 +02:00
parent e29397ca5c
commit d5f5f92f48

View File

@ -34,16 +34,23 @@ module.exports = {
const output = fs.createWriteStream(artifactFilePath);
const files = globby.sync(patterns, {
cwd: this.serverless.config.servicePath,
dot: true,
silent: true,
follow: true,
});
if (files.length === 0) {
const err = new this.serverless.classes.Error('No file matched by your include/exclude patterns');
return new BbPromise((resolve, reject) => {
reject(err);
});
}
output.on('open', () => {
zip.pipe(output);
const files = globby.sync(patterns, {
cwd: this.serverless.config.servicePath,
dot: true,
silent: true,
follow: true,
});
files.forEach((filePath) => {
const fullPath = path.resolve(
this.serverless.config.servicePath,