Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0a54521

Browse files
committed
log all commands and fs actions for debugging
Signed-off-by: shmck <[email protected]>
1 parent fc9218c commit 0a54521

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/services/node/index.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,40 @@ interface ExecParams {
1717

1818
// correct paths to be from workspace root rather than extension folder
1919
const getWorkspacePath = (...paths: string[]) => {
20-
return join(WORKSPACE_ROOT, ...paths)
20+
const workspacePath = join(WORKSPACE_ROOT, ...paths)
21+
logger(`Workspace path: ${workspacePath}`)
22+
return workspacePath
2123
}
2224

2325
export const exec = (params: ExecParams): Promise<{ stdout: string; stderr: string }> | never => {
2426
const cwd = join(WORKSPACE_ROOT, params.dir || '')
27+
logger(`Calling command: ${params.command}`)
2528
return asyncExec(params.command, { cwd })
2629
}
2730

2831
export const exists = (...paths: string[]): boolean | never => {
29-
return fs.existsSync(getWorkspacePath(...paths))
32+
const filePath = getWorkspacePath(...paths)
33+
logger(`Check file exists: ${filePath}`)
34+
return fs.existsSync(filePath)
3035
}
3136

3237
export const removeFile = (...paths: string[]) => {
33-
return asyncRemoveFile(getWorkspacePath(...paths))
38+
const filePath = getWorkspacePath(...paths)
39+
logger(`Removing file: ${filePath}`)
40+
return asyncRemoveFile(filePath)
3441
}
3542

3643
export const readFile = (...paths: string[]): Promise<string | void> => {
3744
const filePath = getWorkspacePath(...paths)
45+
logger(`Reading file: ${filePath}`)
3846
return asyncReadFile(getWorkspacePath(...paths), 'utf8').catch((err) => {
3947
logger(`Failed to read from ${filePath}: ${err.message}`)
4048
})
4149
}
4250

4351
export const writeFile = (data: any, ...paths: string[]): Promise<void> => {
4452
const filePath = getWorkspacePath(...paths)
53+
logger(`Writing file: ${filePath}`)
4554
return asyncWriteFile(filePath, data).catch((err) => {
4655
logger(`Failed to write to ${filePath}: ${err.message}`)
4756
})

0 commit comments

Comments
 (0)