Skip to content

Instantly share code, notes, and snippets.

@devmanhinton
Created October 7, 2013 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devmanhinton/6875413 to your computer and use it in GitHub Desktop.
Save devmanhinton/6875413 to your computer and use it in GitHub Desktop.
Fun times with combining javascript files
1 #!/bin/bash
2 pushd ~/Amicus/suspendors_project/suspendersTest/client_side_js
3 if [ -e "bundle.js" ]
4 then
5 echo "removing old bundle.js"
6 rm -f bundle.js
7 fi
8 if [ -e "main.js" ]
9 then
10 echo "removing old bundle.js"
11 rm -f main.js
12 fi
13 echo "Creating new JSbundle to send client side"
14 browserify -r backbone -r end-dash > bundle.js
15 echo "Creating backbone views etc.. to send"
16 touch main.js
17
18 #combine all JS files to one file the unix shell way
19 if [ "$(ls -A models)" ]
20 then
21 for file in ~/Amicus/suspendors_project/suspendersTest/client_side_js/models/*
22 do
23 cat main.js space "$file" space > main.js
24 done
25 fi
26
27 if [ "$(ls -A views)" ]
28 then
29 for file in ~/Amicus/suspendors_project/suspendersTest/client_side_js/views/*
30 do
31 cat main.js space "$file" space > main.js
32 done
33 fi
34
35 if [ "$(ls -A routers)" ]
36 then
37 for file in ~/Amicus/suspendors_project/suspendersTest/client_side_js/routers/*
38 do
39 cat main.js space "$file" space > main.js
40 done
41 fi
42
43 popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment