From 78f4e8f36b63559c8ad0ed1b7268106c433e3178 Mon Sep 17 00:00:00 2001 From: Loki <59907407+Loki-101@users.noreply.github.com> Date: Thu, 17 Aug 2023 18:38:17 -0700 Subject: [PATCH] Fix error in startup command Changed ``if [[ "${MAIN_FILE}" == *.js ]]`` To ``if [[ "${MAIN_FILE}" == "*.js" ]]`` The *.js without quotes compared MAIN_FILE to all files in the current directory that end with .js, resulting in errors like: ```bash :/home/container$ if [[ -d .git ]] && [[ ${AUTO_UPDATE} == "1" ]]; then git pull; fi; if [[ ! -z ${NODE_PACKAGES} ]]; then /usr/local/bin/npm install ${NODE_PACKAGES}; fi; if [[ ! -z ${UNNODE_PACKAGES} ]]; then /usr/local/bin/npm uninstall ${UNNODE_PACKAGES}; fi; if [ -f /home/container/package.json ]; then /usr/local/bin/npm install; fi; if [[ "${MAIN_FILE}" == start.js test.js ]]; then /usr/local/bin/node "/home/container/${MAIN_FILE}"; else /usr/local/bin/ts-node "${MAIN_FILE}"; fi /entrypoint.sh: eval: line 16: syntax error in conditional expression /entrypoint.sh: eval: line 16: syntax error near `test.js' /entrypoint.sh: eval: line 16: `if [[ -d .git ]] && [[ ${AUTO_UPDATE} == "1" ]]; then git pull; fi; if [[ ! -z ${NODE_PACKAGES} ]]; then /usr/local/bin/npm install ${NODE_PACKAGES}; fi; if [[ ! -z ${UNNODE_PACKAGES} ]]; then /usr/local/bin/npm uninstall ${UNNODE_PACKAGES}; fi; if [ -f /home/container/package.json ]; then /usr/local/bin/npm install; fi; if [[ "${MAIN_FILE}" == start.js test.js ]]; then /usr/local/bin/node "/home/container/${MAIN_FILE}"; else /usr/local/bin/ts-node "${MAIN_FILE}"; fi' ``` because it's interpreted as ``if [[ "${MAIN_FILE}" == start.js test.js ]];`` --- generic/nodejs/egg-node-js-generic.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/generic/nodejs/egg-node-js-generic.json b/generic/nodejs/egg-node-js-generic.json index ae495ddb..8cc30526 100644 --- a/generic/nodejs/egg-node-js-generic.json +++ b/generic/nodejs/egg-node-js-generic.json @@ -4,7 +4,7 @@ "version": "PTDL_v2", "update_url": null }, - "exported_at": "2023-08-13T19:33:59+02:00", + "exported_at": "2023-08-17T18:34:59-07:00", "name": "node.js generic", "author": "parker@parkervcp.com", "description": "a generic node.js egg\r\n\r\nThis will clone a git repo. it defaults to master if no branch is specified.\r\n\r\nInstalls the node_modules on install. If you set user_upload then I assume you know what you are doing.", @@ -19,7 +19,7 @@ "Nodejs 12": "ghcr.io\/parkervcp\/yolks:nodejs_12" }, "file_denylist": [], - "startup": "if [[ -d .git ]] && [[ {{AUTO_UPDATE}} == \"1\" ]]; then git pull; fi; if [[ ! -z ${NODE_PACKAGES} ]]; then \/usr\/local\/bin\/npm install ${NODE_PACKAGES}; fi; if [[ ! -z ${UNNODE_PACKAGES} ]]; then \/usr\/local\/bin\/npm uninstall ${UNNODE_PACKAGES}; fi; if [ -f \/home\/container\/package.json ]; then \/usr\/local\/bin\/npm install; fi; if [[ \"${MAIN_FILE}\" == *.js ]]; then \/usr\/local\/bin\/node \"\/home\/container\/${MAIN_FILE}\"; else \/usr\/local\/bin\/ts-node \"${MAIN_FILE}\"; fi", + "startup": "if [[ -d .git ]] && [[ {{AUTO_UPDATE}} == \"1\" ]]; then git pull; fi; if [[ ! -z ${NODE_PACKAGES} ]]; then \/usr\/local\/bin\/npm install ${NODE_PACKAGES}; fi; if [[ ! -z ${UNNODE_PACKAGES} ]]; then \/usr\/local\/bin\/npm uninstall ${UNNODE_PACKAGES}; fi; if [ -f \/home\/container\/package.json ]; then \/usr\/local\/bin\/npm install; fi; if [[ \"${MAIN_FILE}\" == \"*.js\" ]]; then \/usr\/local\/bin\/node \"\/home\/container\/${MAIN_FILE}\"; else \/usr\/local\/bin\/ts-node \"${MAIN_FILE}\"; fi", "config": { "files": "{}", "startup": "{\r\n \"done\": [\r\n \"change this text 1\",\r\n \"change this text 2\"\r\n ]\r\n}", @@ -74,16 +74,6 @@ "rules": "required|boolean", "field_type": "text" }, - { - "name": "Main file", - "description": "The file that starts the app.\r\nCan be .js and .ts", - "env_variable": "MAIN_FILE", - "default_value": "index.js", - "user_viewable": true, - "user_editable": true, - "rules": "required|string", - "field_type": "text" - }, { "name": "Additional Node packages", "description": "Install additional node packages.\r\n\r\nUse spaces to separate.", @@ -123,6 +113,16 @@ "user_editable": true, "rules": "nullable|string", "field_type": "text" + }, + { + "name": "Main file", + "description": "The file that starts the app.\r\nCan be .js and .ts", + "env_variable": "MAIN_FILE", + "default_value": "index.js", + "user_viewable": true, + "user_editable": true, + "rules": "required|string", + "field_type": "text" } ] }