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

refactor: Use async in lib/plugins/package #9644

Merged
merged 3 commits into from
Jul 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/plugins/package/lib/packageService.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ module.exports = {
if (shouldPackageService && !this.serverless.service.package.artifact) await this.packageAll();
},

packageAll() {
async packageAll() {
const zipFileName = `${this.serverless.service.service}.zip`;

return this.resolveFilePathsAll().then((filePaths) =>
Expand Down Expand Up @@ -145,7 +145,7 @@ module.exports = {
return artifactPath;
},

packageLayer(layerName) {
async packageLayer(layerName) {
const layerObject = this.serverless.service.getLayer(layerName);

const zipFileName = `${layerName}.zip`;
Expand Down Expand Up @@ -204,7 +204,7 @@ module.exports = {
);
},

resolveFilePathsFromPatterns(params, prefix) {
async resolveFilePathsFromPatterns(params, prefix) {
const patterns = [];
const devDependencyExcludeSet = params.devDependencyExcludeSet || new Set();

Expand Down
8 changes: 4 additions & 4 deletions lib/plugins/package/lib/zipService.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = {
return params;
},

zip(params) {
async zip(params) {
return this.resolveFilePathsFromPatterns(params).then((filePaths) =>
this.zipFiles(filePaths, params.zipFileName)
);
Expand All @@ -56,7 +56,7 @@ module.exports = {
* @param zipFiles - the filename to save the zip at
* @param prefix - a prefix to strip from the file names. use for layers support
*/
zipFiles(files, zipFileName, prefix) {
async zipFiles(files, zipFileName, prefix) {
if (files.length === 0) {
const error = new ServerlessError('No files to package', 'NO_FILES_TO_PACKAGE');
return BbPromise.reject(error);
Expand Down Expand Up @@ -103,7 +103,7 @@ module.exports = {
});
},

getFileContentAndStat(filePath) {
async getFileContentAndStat(filePath) {
const fullPath = path.resolve(this.serverless.serviceDir, filePath);

return BbPromise.all([
Expand Down Expand Up @@ -131,7 +131,7 @@ module.exports = {
},
};

function excludeNodeDevDependencies(serviceDir) {
async function excludeNodeDevDependencies(serviceDir) {
const exAndIn = {
include: [],
exclude: [],
Expand Down
5 changes: 3 additions & 2 deletions lib/plugins/package/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ class Package {
);
}
},
'package:createDeploymentArtifacts': () => BbPromise.bind(this).then(this.packageService),
'package:createDeploymentArtifacts': async () =>
BbPromise.bind(this).then(this.packageService),

'package:function:package': () => {
'package:function:package': async () => {
if (this.options.function) {
this.serverless.cli.log(`Packaging function: ${this.options.function}...`);
return BbPromise.resolve(this.packageFunction(this.options.function));
Expand Down