8000 Merge pull request #36 from ShMcK/fix/git-reliability · coderoad/coderoad-vscode@95de6dd · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 95de6dd

Browse files
authored
Merge pull request #36 from ShMcK/fix/git-reliability
fix open file not working - revert
2 parents a3c0fb0 + 493283c commit 95de6dd

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

src/actions/setupActions.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ const commandErrorMessageFilter: ErrorMessageFilter = {
1717
}
1818
}
1919

20-
const runCommands = async (commands: string[], language: string) => {
20+
21+
// TODO: pass command and command name down for filtering. Eg. JAVASCRIPT, 'npm install'
22+
const runCommands = async (commands: string[], language: string = 'JAVASCRIPT') => {
2123
for (const command of commands) {
2224
const {stdout, stderr} = await node.exec(command)
2325
if (stderr) {
@@ -43,13 +45,28 @@ const setupActions = async (workspaceRoot: vscode.WorkspaceFolder, {commands, co
4345
}
4446

4547
// run command
46-
48+
await runCommands(commands)
4749

4850
// open files
4951
for (const filePath of files) {
5052
console.log(`OPEN_FILE ${filePath}`)
5153
try {
52-
const absoluteFilePath = join(workspaceRoot.uri.path, filePath)
54+
// TODO: figure out why this does not work
55+
// try {
56+
// const absoluteFilePath = join(workspaceRoot.uri.path, filePath)
57+
// const doc = await vscode.workspace.openTextDocument(absoluteFilePath)
58+
// await vscode.window.showTextDocument(doc, vscode.ViewColumn.One)
59+
// // there are times when initialization leave the panel behind any files opened
60+
// // ensure the panel is redrawn on the right side first
61+
// // webview.createOrShow(vscode.ViewColumn.Two)
62+
// } catch (error) {
63+
// console.log(`Failed to open file ${filePath}`, error)
64+
// }
65+
const wr = vscode.workspace.rootPath
66+
if (!wr) {
67+
throw new Error('No workspace root path')
68+
}
69+
const absoluteFilePath = join(wr, filePath)
5370
const doc = await vscode.workspace.openTextDocument(absoluteFilePath)
5471
await vscode.window.showTextDocument(doc, vscode.ViewColumn.One)
5572
// there are times when initialization leave the panel behind any files opened
@@ -61,4 +78,6 @@ const setupActions = async (workspaceRoot: vscode.WorkspaceFolder, {commands, co
6178
}
6279
}
6380

64-
export default setupActions
81+
export default setupActions
82+
83+

src/services/git/gitAction.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import node from '../node'
2+
3+
interface GitAction {
4+
command: string
5+
onError?(stderr: string): any
6+
onSuccess?(stdout: string): any
7+
}
8+
9+
// handle common node.exec logic
10+
export const gitAction = async ({command, onError, onSuccess}: GitAction) => {
11+
const {stdout, stderr} = await node.exec(command)
12+
if (onError && stderr) {
13+
return onError(stderr)
14+
} else if (onSuccess && stdout) {
15+
return onSuccess(stdout)
16+
}
17+
}

0 commit comments

Comments
 (0)
0