Git Product home page Git Product logo

Comments (4)

NQNStudios avatar NQNStudios commented on June 23, 2024

I've started sketching out how I might do this myself...

import js.node.ChildProcess;
import js.node.child_process.ChildProcess as ChildProcessObject;

class NodeProcess {
    // https://github.com/HaxeFoundation/hxnodejs/blob/master/src/js/node/child_process/ChildProcess.hx
    var process:ChildProcessObject;

    public function new(cmd:String, ?args:Array<String>, ?detached:Bool) {
        process = ChildProcess.spawn(cmd, args, {detached: detached});
    }

    // TODO provide stderr by wrapping process's stderr js.node.stream.IReadable in an object that implements haxe.io.Input
    // TODO provide stdin by wrapping process's stdin js.node.stream.IWriteable in an object that implements haxe.io.Output
    // TODO provide stdout by wrapping process's stdout js.node.stream.IReadable in an object that implements haxe.io.Input

    // TODO provide close() by calling process's disconnect() method
    // TODO provide kill() by calling process's kill() method
    // TODO not sure how to provide exitCode(), which has no equivalent in ChildProcessObject
}

I'm stumped on how to get the exit code from a ChildProcessObject. Everything else I think I can do, if I just put the time in and muddle through it.

If I could implement this feature, would it be merged @nadako?

from hxnodejs.

nadako avatar nadako commented on June 23, 2024

If it works - then yeah I guess :) Tho sys.io.Process is awkward, I thought nobody uses it ^^

from hxnodejs.

NQNStudios avatar NQNStudios commented on June 23, 2024

I use it as a cross-target interface for running console commands. Is there something better for that, or do people just use target-specific APIs like node's child_process?

from hxnodejs.

NQNStudios avatar NQNStudios commented on June 23, 2024

After implementing and testing my proposed approach, I'm convinced it's not actually possible to provide Process's synchronous API in single-threaded JavaScript.

from hxnodejs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.