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

Allow pipe from cli #151

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

jchoi2x
Copy link

@jchoi2x jchoi2x commented Dec 27, 2017

Added ability to take input from stdin so that html can be piped in.

Executing
cat test/test.htm | htmltojsx --className 'Tst'
results in same output as
htmltojsx -c 'Tst' ./test/test.htm

var Tst = React.createClass({
  render: function() {
    return (
      <div>
        <meta httpEquiv="Content-Type" charSet="UTF-8" />
        <title>React-Magic Tests</title>
        <link rel="stylesheet" type="text/css" href="http://cdnjs.cloudflare.com/ajax/libs/jasmine/2.0.0/jasmine.css" />
        {/* Source files */}
        {/* Spec files */}
      </div>
    );
  }
});

Executing echo '<div><p>fun in the sun?</p></div>' | htmltojsx --className 'Tst' results in

var Tst = React.createClass({
  render: function() {
    return (

      <div><p>fun in the sun?</p></div>
    );
  }
});

@DanBuild
Copy link

Deploy preview ready!

Built with commit 1c9b1ad

https://deploy-preview-151--react-magic.netlify.com

var convertInputCb = buildConverterCb(!!argv.className, argv.className);

if (process.stdin.isTTY) {
return fs.readFile(argv._[0], 'utf-8', convertInputCb);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is argv._[0]?

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

Successfully merging this pull request may close these issues.

3 participants