Bash Script -exec syntax

I’m trying to make a Git hook bash script that minifies my JavaScript code.
So far I have come up with this, it just prints the minified JavaScript when I run the script:

#!/bin/sh
find js/ -type f -maxdepth 3 -name \*.js -exec uglifyjs {} +
exit

I’m not sure how to give the uglifyjs any commands and what the output filename should be.

In the terminal it would be:

uglifyjs -o js/app.js js/app.js

So I’m not sure how to reference the file names etc?

  • Aggregating and uglifying javascript in a git pre-commit hook
  • One Solution collect form web for “Bash Script -exec syntax”

    Say:

    find js/ -type f -maxdepth 3 -name \*.js -exec uglifyjs -o {} {} \;
    

    instead. Note the ; instead of the + after the command.

    Git Baby is a git and github fan, let's start git clone.