Parameter parsing for scripts
Understand how the create, update, and deploy commands parse parameters from a Cloud Code script.
読み終わるまでの所要時間 1 分最終更新 2ヶ月前
In the example Script.js, one parameter with name and type is parsed and uploaded to UGS.
rangeNUMERICFor more details, check [Declare parameters in the script].
Append 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:
module.exports.params = { //Parameters declared in service}
If there are any parameters declared in-script from the service, UGS CLI will not update the parameters.
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:
const _ = 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);}
The script defines at the beginning, but then it is overwritten by , so Create script or Update script cannot parse the parameters.
module.exports.paramsmodule.exports = async ...