Create a bash script to compile SCSS into CSS that takes arguments -


how can create bash script compile scss css works different filename , paths?

for example i'm running command compile scss file css file in different directory:

sass test.scss ../css/test2.css 

it's tedious run on , on again, can write makes easier? i'm new bash scripting.

is looking for?

#!/bin/bash f=${1:-test} sass ${f}.scss ../css/${f}.css 

this script runs sass filename.scss ../css/filename.css. if filename (without extension) isn't set first argument defaults test. can update accept more 1 input file.

but not going save time since still have call script instead of sass. replacing command doesn't accomplish anything.

use !sass instead rerun last sass command on same file or !! rerun previous command. bash history.

how use:
save script file, xx.
make xx executable: chmod u+x xx
run without argument on test: ./xx
run filename without extension: ./xx myscssfile

here's version take list of filenames input or default test.scss:

#!/bin/bash function dosass {     if [ $# -eq 0 ]; return; fi     b=${1%.scss}     sass $b.scss ../css/$b.css } if [ $# -eq 0 ];     dosass "test.scss" else     f; dosass $f; done fi 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -