UNPKG

1.59 kBPlain TextView Raw
1clean:
2 rm -rf ./src
3 rm -rf ./public
4 rm -rf ./.storybook
5
6build:
7 mkdir -p ./src
8 mkdir -p ./public
9
10 if [ -d './sources/assets' ]; then \
11 mkdir -p ./public/assets; \
12 cp -R ./sources/assets/* ./public/assets; \
13 fi
14
15 make .pug
16 make .styl
17 make .coffee
18 make .js
19
20 make .public
21
22findPath = findPath() { \
23 file_ext=$$1; \
24 file_handler=$$2; \
25 for filepath in `find ./sources -print | grep "$$file_ext"`; do \
26 if [ $$file_ext = '.pug' ]; then \
27 output_kw='public'; \
28 else \
29 output_kw='src'; \
30 fi; \
31 output_dir=`echo "$$filepath" | sed "s/sources/$${output_kw}/g" | xargs dirname`; \
32 mkdir -p $$output_dir; \
33 $$file_handler $$file_ext $$filepath $$output_dir; \
34 done; \
35}
36
37extHandler = extHandler() { \
38 file_ext=$$1; \
39 source_path=$$2; \
40 output_dir=$$3; \
41 case "$$file_ext" in \
42 '\.pug' ) \
43 pug -P -o $$output_dir $$source_path; \
44 ;; \
45 '\.styl' ) \
46 stylus --out $$output_dir $$source_path; \
47 ;; \
48 '\.coffee' ) \
49 coffee -c -b -o $$output_dir $$source_path; \
50 ;; \
51 '\.js' ) \
52 cp $$source_path $$output_dir; \
53 ;; \
54 * ) \
55 exit 1; \
56 ;; \
57 esac; \
58}
59
60.pug:
61 @$(findPath); $(extHandler); \
62 findPath '\.pug' extHandler
63
64.styl:
65 @$(findPath); $(extHandler); \
66 findPath '\.styl' extHandler
67
68.coffee:
69 @$(findPath); $(extHandler); \
70 findPath '\.coffee' extHandler
71
72.js:
73 @$(findPath); $(extHandler); \
74 findPath '\.js' extHandler
75
76.public:
77 if [ -d './src/public' ]; then \
78 mv ./src/public/* ./public; \
79 rmdir './src/public'; \
80 fi
81
82rebuild: clean
83 if [ -d './sources/stories' ]; then \
84 make story_book; \
85 fi
86 make build