Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitfbf2be0

Browse files
authored
capture error on command failure (coderoad#563)
* capture error on command failureSigned-off-by: shmck <shawn.j.mckay@gmail.com>* log all commands and fs actions for debuggingSigned-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent2b3a672 commitfbf2be0

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

‎scripts/build.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ cd web-app
2828
yarn build
2929
cd ..
3030

31-
# For Windows build: switch the next 2 lines
3231
echo"Bundling webapp..."
3332
if [["$OSTYPE"=="msys" ]];then
3433
# linux subsystem on windows selected

‎src/services/hooks/utils/runCommands.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ const runCommands = async (commands: string[] = []): Promise<void> => {
1111
title:command,
1212
description:'Running process...',
1313
}
14+
logger(`Command:${command}`)
1415
send({type:'COMMAND_START',payload:{process:{ ...process,status:'RUNNING'}}})
1516
letresult:{stdout:string;stderr:string}
1617
try{
1718
result=awaitexec({ command})
18-
logger(`Command output:${JSON.stringify(result)}`)
19+
if(result.stderr){
20+
thrownewError(result.stderr)
21+
}
22+
logger(`Command output:${result.stdout}`)
1923
}catch(error:any){
2024
logger(`Command failed:${error.message}`)
2125
send({type:'',payload:{process:{ ...process,status:'FAIL'}}})

‎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
constgetWorkspacePath=(...paths:string[])=>{
20-
returnjoin(WORKSPACE_ROOT, ...paths)
20+
constworkspacePath=join(WORKSPACE_ROOT, ...paths)
21+
logger(`Workspace path:${workspacePath}`)
22+
returnworkspacePath
2123
}
2224

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

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

3237
exportconstremoveFile=(...paths:string[])=>{
33-
returnasyncRemoveFile(getWorkspacePath(...paths))
38+
constfilePath=getWorkspacePath(...paths)
39+
logger(`Removing file:${filePath}`)
40+
returnasyncRemoveFile(filePath)
3441
}
3542

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

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp