bdkjones / CodeKit2

CodeKit 2 Beta
97 stars 4 forks source link

Hooks Snippet #556

Open bravocado opened 9 years ago

bravocado commented 9 years ago

I found hooks it's really awesome. But, I'm not good in bash scripting. Anyone want to share a snippet? Like duplicating a processed file to another dir, multiple compile output, timestamp, or HTML GZIP.

I guess a thread like this would be helpful for someone like me. :D

subhaze commented 9 years ago

I'm trying to keep up with doing small posts like the above. Any ideas you/anyone have and I'll try to get something going.

This isn't my claim at knowing bash proficiently... but I know it well enough to find my way through it.

I've a draft on generating a sitemap, but not completely happy with the work flow of it... So I've yet to publish it, hopefully I'll have that out the door in a week or two.

theskillwithin commented 9 years ago

I think I spent hours one time just trying to figure out how to cp the css file to another directory and I never got it working. (edit: i realize this is extremely non-usefull info ill be more detailed next time)

bravocado commented 9 years ago

@theskillwithin I think I got it for you. use rsync.

Destination="your/destination/folder"
Source="your/source/folder"

rsync -av $PWD/$Source $PWD/$Destination

$PWD is a command to get your working directory.

bravocado commented 9 years ago

And maybe someone is trying to get multiple CSS files (CodeKit do the compressed, and hook do the rest. Or the reverse), since CodeKit only allowing with 1 output file. Well, you can installing your preprocessor to your machine so you can use their command line tool.

For SASS: gem install sass

For LESS: npm install -g less

After that you can hook your preprocessor file to your preprocessor command line tool.

An example for LESS:

Source="build/less/style.less"
Destination="dist/css/style.css"

lessc $PWD/$Source $PWD/$Destination
subhaze commented 9 years ago

@theskillwithin something like the following should work

cp ${CK_OUTPUT_PATHS//:/ } path/to/dir

The script is executed in context of the directory CodeKit finds its config file (or so it appears) so path/to/dir would be relative to that folder.