test case for custom filetype handler

This commit is contained in:
Hans Fast 2025-11-22 08:07:42 +01:00
commit e6a1082cdf
4 changed files with 48 additions and 0 deletions

34
README.md Normal file
View File

@ -0,0 +1,34 @@
# filetype handler not working as expected
Following the [docs](https://weborigami.org/language/filetypes#custom-file-types), I have created a file `foobar.foo` and a handler `foo.handler.js`.
```text
#foobar.fo
This is the original text
```
```javascript
//foo.handler.js
//I believe this is not being used, because in doctree.js, isUnpackable is false, and toString is not exported by @weborigami/origami anymore ... ?
import { toString } from "@weborigami/origami";
export default {
mediaType: "application/json",
unpack: (packed) => { return {what: "a text file"} }
}
```
```
//config.ori
{
hello = "world"
foo.handler = ./dj.handler.js
}
```
## Expected/Actual results:
When running `ori foobar.foo/`, I would expect to receive an object `{what: "a text file"}` but I receive the original text in `foobar.foo`.

5
config.ori Normal file
View File

@ -0,0 +1,5 @@
{
hello = "world"
foo.handler = ./dj.handler.js
}

8
foo.handler.js Normal file
View File

@ -0,0 +1,8 @@
//I believe this is not being used, because in doctree.js, isUnpackable is false, and toString is not exported by @weborigami/origami anymore ... ?
import { toString } from "@weborigami/origami";
export default {
mediaType: "application/json",
unpack: (packed) => { return {what: "a text file"} }
}

1
foobar.foo Normal file
View File

@ -0,0 +1 @@
This is the original text