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

child_process/promises #43055

Closed
axkibe opened this issue May 11, 2022 · 1 comment
Closed

child_process/promises #43055

axkibe opened this issue May 11, 2022 · 1 comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. feature request Issues that request new features to be added to Node.js.

Comments

@axkibe
Copy link
Contributor

axkibe commented May 11, 2022

What is the problem this feature will solve?

There isn't child_process doesn't have /promises API as part of the core.

What is the feature you are proposing to solve the problem?

I'd want to see a child_process/promises part of the core API.. since let's admit, promises are the future since async/await became JS standard a while ago.

I know there is util.promisify as workaround and I know it's very possible to write ones own wrapper like for example below.

But a consistent and comprehensive promises API really should be core.

promises.exec = ( command, options ) =>
    new Promise( ( resolve, reject ) =>
    {
        child.exec( command, options, ( error, stdout, stderr ) =>
        {
            stdout += ''; stderr += '';
            if( options && options.echo )
            {
                console.log( stdout );
                console.log( stderr );
            }
            if( error ) reject( { error: error, out : stdout, err : stderr } );
            else resolve( { out : stdout, err : stderr } );
        } );
    } );

What alternatives have you considered?

util.promisify
own wrappers

Yes it can be worked around. But it isn't nice/comfortable.

@axkibe axkibe added the feature request Issues that request new features to be added to Node.js. label May 11, 2022
@targos
Copy link
Member

targos commented May 11, 2022

Duplicate of #38823

@targos targos marked this as a duplicate of #38823 May 11, 2022
@targos targos closed this as completed May 11, 2022
@targos targos added the duplicate Issues and PRs that are duplicates of other issues or PRs. label May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. feature request Issues that request new features to be added to Node.js.
Projects
None yet
Development

No branches or pull requests

2 participants