liquidsoap-prettier 1.4.6 → 1.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,12 +1,17 @@
1
1
  {
2
2
  "name": "liquidsoap-prettier",
3
- "version": "1.4.6",
3
+ "version": "1.4.7",
4
4
  "description": "Liquidsoap language prettier CLI and plugin",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
7
7
  "bin": {
8
8
  "liquidsoap-prettier": "src/cli.js"
9
9
  },
10
+ "scripts": {
11
+ "build:web": "webpack --config webpack.web.cjs",
12
+ "release": "dune build && npm run build:web && npm publish",
13
+ "liquidsoap-prettier": "node ./src/cli.js"
14
+ },
10
15
  "prettier": {
11
16
  "plugins": [
12
17
  "./src/index.js"
@@ -23,10 +28,5 @@
23
28
  "devDependencies": {
24
29
  "webpack": "^5.89.0",
25
30
  "webpack-cli": "^5.1.4"
26
- },
27
- "scripts": {
28
- "build:web": "webpack --config webpack.web.cjs",
29
- "release": "dune build && npm run build:web && npm publish",
30
- "liquidsoap-prettier": "node ./src/cli.js"
31
31
  }
32
- }
32
+ }
@@ -1,12 +1,19 @@
1
1
  open Js_of_ocaml
2
2
  open Liquidsoap_lang
3
3
 
4
- let () =
5
- Hooks.regexp := Regexp_js.make
4
+ let () = Hooks.regexp := Regexp_js.make
6
5
 
7
6
  let parse content =
8
7
  let content = Js.to_string content in
9
- let json = Liquidsoap_tooling.Parsed_json.parse_string content in
8
+ let json =
9
+ let buf = Buffer.create 0 in
10
+ let formatter = Format.formatter_of_buffer buf in
11
+ try Liquidsoap_tooling.Parsed_json.parse_string ~formatter content
12
+ with _ ->
13
+ Js_error.raise_
14
+ (Js_error.of_error
15
+ (new%js Js.error_constr (Js.string (Buffer.contents buf))))
16
+ in
10
17
  Js._JSON##parse
11
18
  (Js.string (Liquidsoap_lang.Json.to_string ~compact:true json))
12
19