Search code examples
javascriptcapistranominifyuglifyjs

Capistrano post deploy uglify-js hook outputs but doesn't write files


I'm facing a strange issue, that surely isn't difficult, but I can't seem to find out what's causing it. After deploying my app via Capistrano, I'm passing all my css through the yui compressor, using :

 run "find #{current_path}/public/static/css/ -name '*.css' -print0 | xargs -0 -I file #{cmd} file -o file"

A quick look around and a few tests made me decide to use node's uglify-js for JavaScript compression, so I went for a simple

uglify_bin = "uglifyjs"
run "find #{current_path}/public/static/js/ -type f -name '*.js' -print0 | xargs -0 #{uglify_bin}"

in the same recipe. Deployment seems to go fine, but a quick inspection at my js files shows uglifyjs didn't do it's job.

Here's an extract of the console output :

  * executing "find /home/USER/www/project/current/public/static/js/ -type f -name '*.js'| xargs uglifyjs --overwrite"
servers: ["project.com"]
[project.com] executing command
command finished in 127ms

Where am I being a complete idiot (yes, it's the word...) ? Thanks.


Solution

  • Finally found what the probleme was. Here's the line of code the way it finally works :

    run "find #{current_path}/public/static/js/ -name '*.js'| xargs -I file #{uglify_path} --overwrite file"
    

    Obviously, the --overwrite option wasn't were it should have been...