diff --git a/templates/cli/lib/commands/command.js.twig b/templates/cli/lib/commands/command.js.twig index 3a85fca2a..63bde3893 100644 --- a/templates/cli/lib/commands/command.js.twig +++ b/templates/cli/lib/commands/command.js.twig @@ -100,7 +100,11 @@ const {{ service.name | caseLower }}{{ method.name | caseUcfirst }} = async ({ { {% for key, header in method.headers %} '{{ key }}': '{{ header }}', {% endfor %} - }, payload{% if method.type == 'location' %}, 'arraybuffer'{% endif %}); + }, payload{% if method.type == 'location' %}, 'arraybuffer'{% endif %}){% if method.packaging %}.catch(err => { + fs.unlinkSync(archivePath); + throw err + });{% endif %} + } else { const streamFilePath = payload['{{ parameter.name }}']; let id = undefined; @@ -130,7 +134,11 @@ const {{ service.name | caseLower }}{{ method.name | caseUcfirst }} = async ({ { }); payload['{{ parameter.name }}'] = stream; - response = await client.call('{{ method.method | caseLower }}', path, headers, payload{% if method.type == 'location' %}, 'arraybuffer'{% endif %}); + response = await client.call('{{ method.method | caseLower }}', path, headers, payload{% if method.type == 'location' %}, 'arraybuffer'{% endif %}){% if method.packaging %}.catch(err => { + fs.unlinkSync(archivePath); + throw err + });{% endif %} + if (!id) { id = response['$id'];