Reuse template array to produce readable list of available templates

This commit is contained in:
Philipp Muens 2016-07-13 09:02:16 +02:00
parent f17c81a8c9
commit 00a7290bf2

View File

@ -38,10 +38,13 @@ class Create {
'aws-python',
];
const humanReadableTemplateList = `${validTemplates.slice(0, -1)
.join(', ')} and ${validTemplates.slice(-1)}`;
if (validTemplates.indexOf(this.options.template) === -1) {
const errorMessage = [
`Template "${this.options.template}" is not supported.`,
' Supported templates are: "aws-nodejs" and "aws-python".',
` Supported templates are: ${humanReadableTemplateList}.`,
].join('');
throw new this.serverless.classes.Error(errorMessage);
}