开发者

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

开发者 https://www.devze.com 2023-03-25 10:02 出处:网络
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,

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 #{uglif开发者_开发百科y_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.


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...


From the uglifyjs docs:

--overwrite — if the code is read from a file (not from STDIN) and you pass --overwrite then the output will be written in the same file.

So perhaps something like:

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

Will work.

0

精彩评论

暂无评论...
验证码 换一张
取 消