Parameter parsing for scripts
Understand how the create, update, and deploy commands parse parameters from a Cloud Code script.
Read time 1 minuteLast updated 21 hours ago
Create script, Update script, and Deploy commands evaluate parameters from a Cloud Code script. In the example Script.js, one parameter with name
rangeNUMERICAppend Parameter into Cloud Code Script during Fetch
To ensure that the Fetch command is fetching the exact Cloud Code script information from the service, UGS CLI will look up parameters declared for the script in the service. If there are parameters declared from the service and there are no parameter in service script code, the Fetch command will update local script code and declare parameters. This means a section like this might be appended into your local script code:If there are any parameters declared in-script from the service, UGS CLI will not update the parameters.module.exports.params = { //Parameters declared in service}
Parsing Limitations
Create script and Update script evaluate the given Cloud Code script to parse the parameters. As a result, these commands cannot parse parameters if you declare them at the beginning and overwrite/delete them after. For example, this script is problematic:The script definesconst _ = require("lodash-4.17");const NUMBER_OF_SIDES = 6;module.exports.params = { sides: "NUMERIC"};module.exports = async ({ params, context, logger }) => { // ...};// Functions can exist outside of the script wrapperfunction rollDice(sides) { return _.random(1, sides);}
module.exports.paramsmodule.exports = async ...