1

Using react-tools from the terminal, I can run the following script to compile my JSX into JavaScript:

jsx ./assets/src/jsx ./assets/build/js

However, when I try putting the same line of code into a CodeKit hook, nothing happens. Replacing it with mkdir ./dummy works as expected and verifies that the working directory is correct. Providing absolute paths to JSX (/usr/local/bin/jsx) or to the assets doesn't seem to make a difference. Obviously since mkdir works, I know that the hook is being triggered properly.

Just to see if it would work, I have also tried minifying a dummy JavaScript file, which also had no effect:

uglifyjs ./assets/src/jsx/dummy.js

I am absolutely stumped. Has anyone successfully integrated JSX and CodeKit?

  • 1
    Does codekit give you any log of the commands it runs? Or any output (error or otherwise) from the running of the commands? Do you see indication that the process is being started if you watch `top` or `ps` when you tell `CodeKit` to run your commands? – Etan Reisner Sep 07 '14 at 22:27
  • I'm rummaging around for any logs and am not finding any just yet. Honestly I'm not sure what to look for with `top`. I don't see any obvious changes when running the command whether it's from terminal or CodeKit. – Evan Henley Sep 07 '14 at 22:47
  • 1
    Getting it to show up with `top` might be difficult because they aren't likely to hit the top of the list. Using `ps` might be easier (but still difficult because of how quick the commands likely are to finish). Possibly better would be to write a small script which runs the commands and verbosely logs what it is doing and what happens. – Etan Reisner Sep 07 '14 at 22:59
  • 1
    nothing-nothing happens? No error msgs? Are you redirecting std-err to `/dev/null` by any chance? if running a shell script (bash/ksh), `set -vx` is your debugging friend. It will show each line or block of code before it is executed, then a separate line preceded with `+` to show the final command that is actually executed, with any variable substitutions completed. Good luck. – shellter Sep 08 '14 at 01:07
  • @shellter So I managed to get errors to log to a file. The result of `jsx ./assets/src/jsx ./assets/build/js` is `/bin/sh: jsx: command not found`. Using `/usr/local/bin/jsx ...` instead returns `env: node: No such file or directory`. I was under the impression that these were just running regular shell scripts, but I guess something is different. Any idea how to work around this? – Evan Henley Sep 08 '14 at 22:37

1 Answers1

1

Okay, thanks to @Etan and @shellter's help with bash debugging, I managed to get it working. I needed to add a symlink for node to /usr/bin/local. The final script compiles the JSX to JavaScript and then minifies it. This should make working with ReactJS in CodeKit much easier.

# compile JSX to JavaScript 
/usr/local/bin/jsx ./assets/src/jsx ./assets/build/js
# uglify
/usr/local/bin/uglifyjs -o ./assets/build/js/scripts-min.js ./assets/build/js/scripts.js
Community
  • 1
  • 1