Skip to content

Commit d4a2643

Browse files
Merge pull request #410 from PineappleIOnic/fix-delete-archive-on-fail
Fix Archive not being deleted when the deploy request fails
2 parents 65e6433 + 93c3b87 commit d4a2643

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

templates/cli/lib/commands/command.js.twig

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ const {{ service.name | caseLower }}{{ method.name | caseUcfirst }} = async ({ {
105105
{% for key, header in method.headers %}
106106
'{{ key }}': '{{ header }}',
107107
{% endfor %}
108-
}, payload{% if method.type == 'location' %}, 'arraybuffer'{% endif %});
108+
}, payload{% if method.type == 'location' %}, 'arraybuffer'{% endif %}){% if method.packaging %}.catch(err => {
109+
fs.unlinkSync(archivePath);
110+
throw err
111+
});{% endif %}
112+
109113
} else {
110114
const streamFilePath = payload['{{ parameter.name }}'];
111115
let id = undefined;
@@ -135,7 +139,11 @@ const {{ service.name | caseLower }}{{ method.name | caseUcfirst }} = async ({ {
135139
});
136140
payload['{{ parameter.name }}'] = stream;
137141

138-
response = await client.call('{{ method.method | caseLower }}', path, headers, payload{% if method.type == 'location' %}, 'arraybuffer'{% endif %});
142+
response = await client.call('{{ method.method | caseLower }}', path, headers, payload{% if method.type == 'location' %}, 'arraybuffer'{% endif %}){% if method.packaging %}.catch(err => {
143+
fs.unlinkSync(archivePath);
144+
throw err
145+
});{% endif %}
146+
139147

140148
if (!id) {
141149
id = response['$id'];

0 commit comments

Comments
 (0)