Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Electron: child_process: command fail #144

Open
xvno opened this issue Jul 20, 2021 · 1 comment
Open

Electron: child_process: command fail #144

xvno opened this issue Jul 20, 2021 · 1 comment

Comments

@xvno
Copy link
Owner

xvno commented Jul 20, 2021

Refs

@xvno
Copy link
Owner Author

xvno commented Jul 20, 2021

app via electron-build will fail to execute shell commands

Fix, path not set properly, so use fix-path as a shimming tool

npm install -s fix-path
const fixPath = require('fix-path');
const cp = require('child_process');
fixPath();
// ...
// ...
// cmdArgs = ['docker', 'ps', '-a'];
exec(cmdArgs.join(' '), (err, stdout, stderr) => {
        if (err) {
            error(`${apiName}.error: `, err);
            return sendBack(
                backStatus,
                {
                    action,
                    sender,
                    code: CODE.STATE_ERROR,
                    message: MESSAGE.STATE_ERROR,
                    data: { detail: err.errno },
                    taskerid
                });

        }
        if (stderr) {
            log(`${apiName}.stderr: `, stderr);
            return sendBack(backStatus,
                {
                    action,
                    sender,
                    code: CODE.STATE_ERROR,
                    message: MESSAGE.STATE_ERROR,
                    data: { detail: stderr },
                    taskerid
                });
        }
        console.log(`stdout: ${stdout}`);
        log(`${apiName}.stdout: `, stdout);
        sendBack(backStatus, { action, sender, code: CODE.STATE_OK, message: MESSAGE.STATE_OK, data: { detail: stdout }, taskerid });
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant