Skip to content

No output when calling callMain with args #91

@williamfzc

Description

@williamfzc

This project is really cool. Thanks for all your work!

I have followed some related issues (#80) to capture the output, which working fine in some simple cases.

But it seems not work if I sending some args together.

// OK
lg.callMain(["log"])
// NO OUTPUT
lg.callMain(["log", "-p"])

Full snippet:

const lg = require('./node_modules/wasm-git/lg2.js');
let stdout;


lg["print"] = function (text) {
    console.log(text);
}

lg["printErr"] = function (text) {
    console.error(text);
}

lg.onRuntimeInitialized = () => {
    const FS = lg.FS;
    const NODEFS = FS.filesystems.NODEFS;

    FS.mkdir('/working');
    FS.mount(NODEFS, {root: '..'}, '/working');
    FS.chdir('/working');

    const gitConfigContent = '[user]\n' +
        'name = Test User\n' +
        'email = [email protected]\n' +
        '[safe]\ndirectory = *\n';

    FS.writeFile('/home/web_user/.gitconfig', gitConfigContent, (err) => {
        if (err) throw err;
        console.log('File has been saved!');
    });

    console.log(FS.readdir('.'));

    // OK
    lg.callMain(["log"])
    // NO OUTPUT
    lg.callMain(["log", "-p"])
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions