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

Console output from transforms is silently swallowed #81

Closed
spudly opened this issue Dec 24, 2015 · 5 comments
Closed

Console output from transforms is silently swallowed #81

spudly opened this issue Dec 24, 2015 · 5 comments

Comments

@spudly
Copy link

spudly commented Dec 24, 2015

I'm trying to run transformations but having a really hard time because all my files get skipped and I have no indication of why.

Each of the transformation files use console.log() to tell the user why files were skipped, but for whatever reason, the console.log() statements never make it into stdout.

@fkling
Copy link
Contributor

fkling commented Dec 24, 2015

Mmh, not sure. According to the docs, child_process.fork() should forward everything to the parent's stdout by default.

However, even if it worked, I'm not sure it would be useful, since the workers run concurrently and any output produced by the child processes might be intermingled with the output of the parent process.

Have you considered using the stats function instead? It Only works in in dry runs, but lets you output valuably information.

@DrewML
Copy link
Contributor

DrewML commented Jun 21, 2016

Not sure if something changed in the codebase that enabled this, but this works with the current version of jscodeshift. Verified with the following transform:

export default function transformer(file, api) {
    console.log('heyyyyyyy');
    return null;
};

@fkling
Copy link
Contributor

fkling commented Jun 21, 2016

Yep, works fine for me too.

@fkling fkling closed this as completed Jun 21, 2016
euphocat pushed a commit to euphocat/jscodeshift that referenced this issue Oct 22, 2017
In facebook#79, I made it so the transformation is skipped in some cases, in particular
when the capitalization is invalid. This broke an assumption elsewhere in the
code that `convertNodeToJSX` always returns a `JSXElement`, so there was a crash
if a skipped element was used as a child. To fix, we can just wrap in a
`JSXExpressionContainer` for that case.
@danielo515
Copy link

danielo515 commented Dec 4, 2020

This does not shows everything though:

module.exports = function (file, api) {
  const j = api.jscodeshift;
  const { statement } = j.template;
  console.log("Starting"); // this is shown
  return j(file.source)
    .find(j.FunctionExpression)
    .replaceWith((p) => {
      console.log("What the", p); // not logged
      const root = j(p.value);
      const variablesToReplace = {};
      return p;
    });
};

@danielo515
Copy link

sorry, my bad, I was using FunctionExpression to look for ArrowFunctionExpressions. It works.

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

4 participants