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

TypeError while running Exercise 13 (DUPLEXER) and 14 (DUPLEXER REDUX) #271

Open
antosant1981 opened this issue Apr 5, 2022 · 1 comment

Comments

@antosant1981
Copy link

antosant1981 commented Apr 5, 2022

Hello,

I had the follwing error while trying ro run (and verify) exercises 13 and 14:

this.submissionChild = this.submissionFn(this.submissionArgs)
                                ^
TypeError: this.submissionFn is not a function
    at Exercise.<anonymous> (C:\Users\anton\AppData\Roaming\npm\node_modules\stream-adventure\lib\exportFnExercise.js:29:33)
    at next (C:\Users\anton\AppData\Roaming\npm\node_modules\stream-adventure\node_modules\workshopper-exercise\exercise.js:170:19)
    at Exercise.process (C:\Users\anton\AppData\Roaming\npm\node_modules\stream-adventure\node_modules\workshopper-exercise\exercise.js:177:5)
    at Exercise.<anonymous> (C:\Users\anton\AppData\Roaming\npm\node_modules\stream-adventure\node_modules\workshopper-exercise\exercise.js:147:10)
    at processTicksAndRejections (node:internal/process/task_queues:78:11)

Find below the code of the challenge 13.

This is the script with the function to export (named child.js):

const { spawn } = require('child_process');
const duplexer2 = require('duplexer2');


module.exports = function (cmd, args, opts) {
    // spawn the process and return a single stream
    const command = spawn(cmd, args, opts);

    // readable is obtained using the command stdout
    const readable = command.stdout;

    // writable is obtained using the command stdin
    const writable = command.stdin;

    // joining together the stdin and stdout here
    return duplexer2(writable, readable);
  }

This is the script that uses the function exported:

const child = require('./child');

const command = child('dir', [], { shell: true });

command.pipe(process.stdout);

Can you tell me what's wrong please and possibly suggest a solution?

@antosant1981 antosant1981 changed the title TypeError while running Exercise 13 (DEPLEXER) and 14 (DUPLEXER REDUX) TypeError while running Exercise 13 (DUPLEXER) and 14 (DUPLEXER REDUX) Apr 5, 2022
@ccarruitero
Copy link
Contributor

Hi @antosant1981

Your solution (exported function) seems correct.

Not sure how you are running the verify script? You just need to run the verify script with your function file as parameter.

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

2 participants