mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-10-25 05:27:26 +08:00
1.4 KiB
1.4 KiB
| name | parameters | parameter_types | ||||||
|---|---|---|---|---|---|---|---|---|
| require_glob |
|
|
require_glob() can recursively load .js files, optionally non-recursive as well.
Possible parameters are:
- Path as string, where you would like to start including files. Mandatory. Pattern matching possible, see GoLand path/filepath/#Match docs.
- If being recursive. This is a boolean if the search should be recursive or not. Define either
trueorfalse. Default istrue.
Example to load .js files recursively:
{% code title="dnsconfig.js" %}
require_glob("./domains/");
{% endcode %}
Example to load .js files only in domains/:
{% code title="dnsconfig.js" %}
require_glob("./domains/", false);
{% endcode %}
One more important thing to note: require_glob() is as smart as require() is. It loads files always relative to the JavaScript
file where it's being executed in. Let's go with an example, as it describes it better:
{% code title="dnsconfig.js" %}
require("domains/index.js");
{% endcode %}
{% code title="domains/index.js" %}
require_glob("./user1/");
{% endcode %}
This will now load files being present underneath ./domains/user1/ and NOT at below ./domains/, as require_glob()
is called in the subfolder domains/.