File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,20 +4,31 @@ class Theme < Base
44 summary 'Create files for theme customization'
55
66 usage 'madness theme full [PATH]'
7+ usage 'madness theme css'
78 usage 'madness config (-h|--help)'
89
910 command 'full' , 'Create a full theme customization directory in PATH [default: _theme]'
11+ command 'css' , 'Create a folder with the CSS file for customization'
1012
1113 def full_command
12- raise InitError , "Directory #{ path } already exists" if Dir . exist? path
14+ raise InitError , "Directory #{ theme_path } already exists" if Dir . exist? theme_path
1315
14- FileUtils . cp_r File . expand_path ( '../../../app' , __dir__ ) , path
15- say "!txtgrn!Created #{ path } theme folder"
16+ FileUtils . cp_r File . expand_path ( '../../../app' , __dir__ ) , theme_path
17+ say "!txtgrn!Created #{ theme_path } theme folder"
18+ end
19+
20+ def css_command
21+ file = 'css/main.css'
22+ raise InitError , "File #{ file } already exists" if File . exist? file
23+
24+ FileUtils . mkdir_p 'css'
25+ FileUtils . cp_r File . expand_path ( '../../../app/public/css/main.css' , __dir__ ) , 'css/main.css'
26+ say '!txtgrn!Created css/main.css'
1627 end
1728
1829 private
1930
20- def path
31+ def theme_path
2132 args [ 'PATH' ] || '_theme'
2233 end
2334 end
Original file line number Diff line number Diff line change 1+ Created css/main.css
Original file line number Diff line number Diff line change 1+ #<Madness::InitError: File css/main.css already exists>
Original file line number Diff line number Diff line change @@ -2,12 +2,16 @@ Create files for theme customization
22
33Usage:
44 madness theme full [PATH]
5+ madness theme css
56 madness config (-h|--help)
67
78Commands:
89 full
910 Create a full theme customization directory in PATH [default: _theme]
1011
12+ css
13+ Create a folder with the CSS file for customization
14+
1115Options:
1216 -h --help
1317 Show this help
Original file line number Diff line number Diff line change 11Usage:
22 madness theme full [PATH]
3+ madness theme css
34 madness config (-h|--help)
Original file line number Diff line number Diff line change 3737 end
3838 end
3939 end
40+
41+ context 'with css command' do
42+ let ( :theme_dir ) { 'tmp/css' }
43+
44+ before do
45+ system "rm -rf #{ theme_dir } " if Dir . exist? theme_dir
46+ expect ( Dir ) . not_to exist theme_dir
47+ end
48+
49+ it 'copies the public css to css/main.css' do
50+ Dir . chdir 'tmp' do
51+ expect { subject . execute 'theme css' } . to output_approval ( 'cli/theme/css-create' )
52+ expect ( Dir ) . to exist 'css'
53+ expect ( File . read ( 'css/main.css' ) ) . to eq File . read ( '../app/public/css/main.css' )
54+ end
55+ end
56+
57+ context 'when dir already exists' do
58+ before do
59+ system "mkdir #{ theme_dir } " unless Dir . exist? theme_dir
60+ system "touch #{ theme_dir } /main.css"
61+ end
62+
63+ it 'does not overwrite it' do
64+ Dir . chdir 'tmp' do
65+ expect { subject . execute 'theme css' } . to raise_approval ( 'cli/theme/css-exists' )
66+ end
67+ end
68+ end
69+ end
4070end
You can’t perform that action at this time.
0 commit comments