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

capture error on command failure#563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 2 commits intomasterfromcapture-command-error-logs
Jan 9, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletionscripts/build.sh
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,6 @@ cd web-app
yarn build
cd ..

# For Windows build: switch the next 2 lines
echo "Bundling webapp..."
if [[ "$OSTYPE" == "msys" ]]; then
# linux subsystem on windows selected
Expand Down
6 changes: 5 additions & 1 deletionsrc/services/hooks/utils/runCommands.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,11 +11,15 @@ const runCommands = async (commands: string[] = []): Promise<void> => {
title: command,
description: 'Running process...',
}
logger(`Command: ${command}`)
send({ type: 'COMMAND_START', payload: { process: { ...process, status: 'RUNNING' } } })
let result: { stdout: string; stderr: string }
try {
result = await exec({ command })
logger(`Command output: ${JSON.stringify(result)}`)
if (result.stderr) {
throw new Error(result.stderr)
}
logger(`Command output: ${result.stdout}`)
} catch (error: any) {
logger(`Command failed: ${error.message}`)
send({ type: '', payload: { process: { ...process, status: 'FAIL' } } })
Expand Down
15 changes: 12 additions & 3 deletionssrc/services/node/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,31 +17,40 @@ interface ExecParams {

// correct paths to be from workspace root rather than extension folder
const getWorkspacePath = (...paths: string[]) => {
return join(WORKSPACE_ROOT, ...paths)
const workspacePath = join(WORKSPACE_ROOT, ...paths)
logger(`Workspace path: ${workspacePath}`)
return workspacePath
}

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

export const exists = (...paths: string[]): boolean | never => {
return fs.existsSync(getWorkspacePath(...paths))
const filePath = getWorkspacePath(...paths)
logger(`Check file exists: ${filePath}`)
return fs.existsSync(filePath)
}

export const removeFile = (...paths: string[]) => {
return asyncRemoveFile(getWorkspacePath(...paths))
const filePath = getWorkspacePath(...paths)
logger(`Removing file: ${filePath}`)
return asyncRemoveFile(filePath)
}

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

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

[8]ページ先頭

©2009-2025 Movatter.jp