Scripting

/doc/module/scripting.md (729 B)

 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Process

This is a module for [Project Forge](https://projectforge.dev). It allows the execution of JavaScript files using a built-in interpreter.

https://github.com/kyleu/projectforge/tree/master/module/scripting

### License

Licensed under [CC0](https://creativecommons.org/publicdomain/zero/1.0)

### Usage

Create a new `Script` service by calling `scripting.NewService(filesystem.NewService("./data"), "scripts")`.

A UI is provided for ad-hoc scripting and filesystem management.

Your scripts can expose test case examples that will automatically be run:

```javascript
function test(name, t) {
return `Hello [${name}] from [${t}] script`;
}

const examples = {
"test": [["a", "x"], ["b", "y"], ["c", "z"]]
};
```