Skip to content

Commit 2f2b56e

Browse files
committed
Ensure function is still deployed even if variables are not
1 parent 31a484f commit 2f2b56e

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

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

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -213,33 +213,36 @@ const deployFunction = async ({ functionId, all, yes } = {}) => {
213213
});
214214

215215
if (remoteVariables.length > 0) {
216+
let override = yes;
216217
if (!yes) {
217218
const variableAnswers = await inquirer.prompt(questionsDeployFunctions[1])
218-
219-
if (variableAnswers.override !== "YES") {
220-
log(`Received "${variableAnswers.override}". Skipping ${func.name} ( ${func['$id']} )`);
221-
continue;
222-
}
219+
override = variableAnswers.override === "YES";
223220
}
224221

225-
await Promise.all(remoteVariables.map(async remoteVariable => {
226-
await functionsDeleteVariable({
227-
functionId: func['$id'],
228-
variableId: remoteVariable['$id'],
229-
parseOutput: false
230-
});
231-
}));
222+
if (!override) {
223+
log(`Skipping variables for ${func.name} ( ${func['$id']} )`);
224+
} else {
225+
log(`Deploying variables for ${func.name} ( ${func['$id']} )`);
226+
227+
await Promise.all(remoteVariables.map(async remoteVariable => {
228+
await functionsDeleteVariable({
229+
functionId: func['$id'],
230+
variableId: remoteVariable['$id'],
231+
parseOutput: false
232+
});
233+
}));
234+
235+
// Deploy local variables
236+
await Promise.all(Object.keys(func.variables).map(async localVariableKey => {
237+
await functionsCreateVariable({
238+
functionId: func['$id'],
239+
key: localVariableKey,
240+
value: func.variables[localVariableKey],
241+
parseOutput: false
242+
});
243+
}));
244+
}
232245
}
233-
234-
// Deploy local variables
235-
await Promise.all(Object.keys(func.variables).map(async localVariableKey => {
236-
await functionsCreateVariable({
237-
functionId: func['$id'],
238-
key: localVariableKey,
239-
value: func.variables[localVariableKey],
240-
parseOutput: false
241-
});
242-
}));
243246
}
244247

245248
response = await functionsUpdate({

0 commit comments

Comments
 (0)