Skip to content

Commit dadb4ed

Browse files
committed
docs: create debugging.md
1 parent 58ff472 commit dadb4ed

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Debugging
2+
> How to deal with errors in the extension
3+
4+
## Test shell commands
5+
6+
This snippet of code can be used to for testing that a basic command works without error and output can be shown.
7+
8+
```typescript
9+
/**
10+
* Debug tool for checking that a basic command works.
11+
* Replace the `makeAndFillCommitMsg` call with `test` to use this.
12+
*/
13+
async function _test(repository: Repository) {
14+
vscode.window.showInformationMessage("Testing")
15+
16+
let cwd = repository.rootUri.path;
17+
18+
vscode.window.showInformationMessage(cwd)
19+
20+
const resp = await _execute(cwd, 'git --version')
21+
vscode.window.showInformationMessage(`${resp.stdout} -- ${resp.stderr}`)
22+
}
23+
```
24+
25+
### Background
26+
27+
This was prompted by issue [#93](https://github.com/MichaelCurrin/auto-commit-msg/issues/93) on Windows.
28+
29+
The output in the debug mode did not work because the shell command failed to spawn at all using `exec()` in Node.
30+
31+
I printed the `cwd` value in the VS Code info box using code above. I realized that when it was used with `git` in `cmd` on Windows that the path was not valid. Showing as `/c:/...` with a leading forward-slash appropriate for Linux/macOS but not Windows `cmd`.
32+
33+
This is the temporary hack until the `vscode` library has a fix:
34+
35+
```typescript
36+
cwd = cwd.replace("/c:/", "c:/")
37+
```

0 commit comments

Comments
 (0)