From 9fadd58a6c78ee57d3c159f30c6b80288d8acb65 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sat, 27 Mar 2021 15:17:42 +0100 Subject: [PATCH] Remove escape character --- .../11.helpers/packaging_apps_helpers.md | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/pages/04.contribute/04.packaging_apps/11.helpers/packaging_apps_helpers.md b/pages/04.contribute/04.packaging_apps/11.helpers/packaging_apps_helpers.md index 9ab374f1..fd1994b1 100644 --- a/pages/04.contribute/04.packaging_apps/11.helpers/packaging_apps_helpers.md +++ b/pages/04.contribute/04.packaging_apps/11.helpers/packaging_apps_helpers.md @@ -1614,7 +1614,27 @@ Requires YunoHost version 2.7.2 or higher.

**Details**: -ynh\_use\_nodejs has to be used in any app scripts before using node for the first time.
This helper will provide alias and variables to use in your scripts.

To use npm or node, use the alias `ynh\_npm` and `ynh\_node`
Those alias will use the correct version installed for the app
For example: use `ynh\_npm install` instead of `npm install`

With `sudo` or `ynh\_exec\_as`, use instead the fallback variables `$ynh\_npm` and `$ynh\_node`
And propagate $PATH to sudo with $ynh\_node\_load\_PATH
Exemple: `ynh\_exec\_as $app $ynh\_node\_load\_PATH $ynh\_npm install`

$PATH contains the path of the requested version of node.
However, $PATH is duplicated into $node\_PATH to outlast any manipulation of $PATH
You can use the variable `$ynh\_node\_load\_PATH` to quickly load your node version
in $PATH for an usage into a separate script.
Exemple: $ynh\_node\_load\_PATH $final\_path/script\_that\_use\_npm.sh`

Finally, to start a nodejs service with the correct version, 2 solutions
Either the app is dependent of node or npm, but does not called it directly.
In such situation, you need to load PATH
`Environment="\_\_NODE\_ENV\_PATH\_\_"`
`ExecStart=\_\_FINALPATH\_\_/my\_app`
You will replace \_\_NODE\_ENV\_PATH\_\_ with $ynh\_node\_load\_PATH

Or node start the app directly, then you don't need to load the PATH variable
`ExecStart=\_\_YNH\_NODE\_\_ my\_app run`
You will replace \_\_YNH\_NODE\_\_ with $ynh\_node

2 other variables are also available
- $nodejs\_path: The absolute path to node binaries for the chosen version.
- $nodejs\_version: Just the version number of node for this app. Stored as 'nodejs\_version' in settings.yml.

Requires YunoHost version 2.7.12 or higher.

+`ynh_use_nodejs` has to be used in any app scripts before using node for the first time.
+This helper will provide alias and variables to use in your scripts.

+ +To use npm or node, use the alias `ynh_npm` and `ynh_node`
+Those alias will use the correct version installed for the app
+For example: use `ynh_npm install` instead of `npm install`

+ +With `sudo` or `ynh_exec_as`, use instead the fallback variables `$ynh_npm` and `$ynh_node`
+And propagate `$PATH` to sudo with `$ynh_node_load_PATH`
+Exemple: `ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install`

+ +`$PATH` contains the path of the requested version of node.
+However, `$PATH` is duplicated into `$node_PATH` to outlast any manipulation of `$PATH`
+You can use the variable `$ynh_node_load_PATH` to quickly load your node version in `$PATH` for an usage into a separate script.
+ +Exemple: `$ynh_node_load_PATH $final_path/script_that_use_npm.sh`

+Finally, to start a nodejs service with the correct version, two solutions
Either the app is dependent of node or npm, but does not called it directly.
In such situation, you need to load PATH
`Environment="__NODE_ENV_PATH__"`
`ExecStart=__FINALPATH__/my_app`
You will replace `__NODE_ENV_PATH__` with `$ynh_node_load_PATH`

+ +Or node start the app directly, then you don't need to load the PATH variable
`ExecStart=__YNH_NODE__ my_app run`
You will replace `__YNH_NODE__` with `$ynh_node`

+ +2 other variables are also available
- `$nodejs_path`: The absolute path to node binaries for the chosen version.
- `$nodejs_version`: Just the version number of node for this app. Stored as `nodejs_version` in `settings.yml`.

Requires YunoHost version 2.7.12 or higher.

[Dude, show me the code!](https://github.com/YunoHost/yunohost/blob/adc83b4c9c2c30e9ef75f3609c538b646f91f1db/data/helpers.d/nodejs#L68)