Skip to content

Commit

Permalink
Revert "Fix Language Server and Tools --version command (#853)"
Browse files Browse the repository at this point in the history
This reverts commit e54c067.
  • Loading branch information
zth committed Dec 18, 2023
1 parent e54c067 commit 9d38eb2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

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

#### :nail_care: Polish

Expand Down
6 changes: 4 additions & 2 deletions server/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env node
const server = require("./server")
import fs from "fs";
import server from "./server";

const args = process.argv.slice(2)

const help = `ReScript Language Server
Expand All @@ -21,7 +23,7 @@ Options:
return server(false);
case '--version':
case '-v':
console.log(require('../package.json').version);
console.log(JSON.parse(fs.readFileSync('./package.json', { encoding: 'utf8' })).version);
process.exit(0);
case '--help':
case '-h':
Expand Down
1 change: 0 additions & 1 deletion tools/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@
#### :bug: Bug Fix

- Fix tagged variant for `Module` and add attr to interface files. https://github.com/rescript-lang/rescript-vscode/pull/866
- Fix `rescript-tools --version` command. https://github.com/rescript-lang/rescript-vscode/pull/853
- 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
6 changes: 3 additions & 3 deletions tools/src/Cli.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@@directive("#!/usr/bin/env node")

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

0 comments on commit 9d38eb2

Please sign in to comment.