Skip to content

Commit 9d38eb2

Browse files
committed
Revert "Fix Language Server and Tools --version command (#853)"
This reverts commit e54c067.
1 parent e54c067 commit 9d38eb2

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

CHANGELOG.md

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
- Proper default for `"uncurried"` in V11 projects. https://github.com/rescript-lang/rescript-vscode/pull/867
2222
- Treat `result` type as a proper built in type. https://github.com/rescript-lang/rescript-vscode/pull/860
23-
- Fix `rescript-language-server --version` command. https://github.com/rescript-lang/rescript-vscode/pull/853
2423

2524
#### :nail_care: Polish
2625

server/src/cli.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env node
2-
const server = require("./server")
2+
import fs from "fs";
3+
import server from "./server";
4+
35
const args = process.argv.slice(2)
46

57
const help = `ReScript Language Server
@@ -21,7 +23,7 @@ Options:
2123
return server(false);
2224
case '--version':
2325
case '-v':
24-
console.log(require('../package.json').version);
26+
console.log(JSON.parse(fs.readFileSync('./package.json', { encoding: 'utf8' })).version);
2527
process.exit(0);
2628
case '--help':
2729
case '-h':

tools/CHANGELOG.md

-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,4 @@
2323
#### :bug: Bug Fix
2424

2525
- Fix tagged variant for `Module` and add attr to interface files. https://github.com/rescript-lang/rescript-vscode/pull/866
26-
- Fix `rescript-tools --version` command. https://github.com/rescript-lang/rescript-vscode/pull/853
2726
- Fix output truncate when run `rescript-tools doc path/to/file.res` in a separate process. https://github.com/rescript-lang/rescript-vscode/pull/868

tools/src/Cli.res

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@@directive("#!/usr/bin/env node")
22

3-
@val external require: string => Js.Dict.t<string> = "require"
3+
@module("fs") external readFileSync: string => string = "readFileSync"
44
@variadic @module("path") external join: array<string> => string = "join"
55
@module("path") external dirname: string => string = "dirname"
66
@val external __dirname: string = "__dirname"
@@ -89,9 +89,9 @@ switch args->Belt.List.fromArray {
8989
}
9090
| list{"-h" | "--help"} => logAndExit(~log=help, ~code=0)
9191
| list{"-v" | "--version"} =>
92-
switch require("../package.json")->Js.Dict.get("version") {
92+
switch readFileSync("./package.json")->Js.Json.parseExn->Js.Json.decodeObject {
9393
| None => logAndExit(~log="error: failed to find version in package.json", ~code=1)
94-
| Some(version) => logAndExit(~log=version, ~code=0)
94+
| Some(dict) => logAndExit(~log=dict->Js.Dict.unsafeGet("version"), ~code=0)
9595
}
9696
| _ => logAndExit(~log=help, ~code=1)
9797
}

0 commit comments

Comments
 (0)