@@ -2,7 +2,7 @@ require 'yaml'
2
2
include FileUtils
3
3
4
4
content = File . open ( 'angularFiles.js' , 'r' ) { |f | f . read }
5
- files = eval ( content . gsub ( /\} ;(\s |\S )*/ , '}' ) . gsub ( /angularFiles = / , '' ) . gsub ( /:/ , '=>' ) ) ;
5
+ files = eval ( content . gsub ( /\} ;(\s |\S )*/ , '}' ) . gsub ( /angularFiles = / , '' ) . gsub ( /:/ , '=>' ) . gsub ( / \/ \/ / , '#' ) ) ;
6
6
7
7
BUILD_DIR = 'build'
8
8
34
34
35
35
desc 'Compile Scenario'
36
36
task :compile_scenario => :init do
37
-
38
- deps = [
37
+
38
+ concatFile ( 'angular-scenario.js' , [
39
39
'lib/jquery/jquery.js' ,
40
40
'src/ngScenario/angular.prefix' ,
41
41
files [ 'angularSrc' ] ,
42
42
files [ 'angularScenario' ] ,
43
43
'src/ngScenario/angular.suffix' ,
44
- ]
45
-
46
- concat = 'cat ' + deps . flatten . join ( ' ' )
47
-
48
- File . open ( path_to ( 'angular-scenario.js' ) , 'w' ) do |f |
49
- f . write ( %x{#{ concat } } . gsub ( '"NG_VERSION_FULL"' , NG_VERSION . full ) )
50
- f . write ( gen_css ( 'css/angular.css' ) + "\n " )
51
- f . write ( gen_css ( 'css/angular-scenario.css' ) )
52
- end
44
+ ] , gen_css ( 'css/angular.css' ) + "\n " + gen_css ( 'css/angular-scenario.css' ) )
53
45
end
54
46
55
47
desc 'Compile JSTD Scenario Adapter'
56
48
task :compile_jstd_scenario_adapter => :init do
57
49
58
- deps = [
50
+ concatFile ( 'jstd-scenario-adapter.js' , [
59
51
'src/ngScenario/jstd-scenario-adapter/angular.prefix' ,
60
52
'src/ngScenario/jstd-scenario-adapter/Adapter.js' ,
61
53
'src/ngScenario/jstd-scenario-adapter/angular.suffix' ,
62
- ]
63
-
64
- concat = 'cat ' + deps . flatten . join ( ' ' )
65
-
66
- File . open ( path_to ( 'jstd-scenario-adapter.js' ) , 'w' ) do |f |
67
- f . write ( %x{#{ concat } } . gsub ( '"NG_VERSION_FULL"' , NG_VERSION . full ) )
68
- end
54
+ ] )
69
55
70
56
# TODO(vojta) use jstd configuration when implemented
71
57
# (instead of including jstd-adapter-config.js)
80
66
desc 'Compile JavaScript'
81
67
task :compile => [ :init , :compile_scenario , :compile_jstd_scenario_adapter ] do
82
68
83
- deps = [
84
- 'src/angular.prefix' ,
85
- files [ 'angularSrc' ] ,
86
- 'src/angular.suffix' ,
87
- ]
88
-
89
- File . open ( path_to ( 'angular.js' ) , 'w' ) do |f |
90
- concat = 'cat ' + deps . flatten . join ( ' ' )
91
-
92
- content = %x{#{ concat } } .
93
- gsub ( '"NG_VERSION_FULL"' , NG_VERSION . full ) .
94
- gsub ( '"NG_VERSION_MAJOR"' , NG_VERSION . major ) .
95
- gsub ( '"NG_VERSION_MINOR"' , NG_VERSION . minor ) .
96
- gsub ( '"NG_VERSION_DOT"' , NG_VERSION . dot ) .
97
- gsub ( '"NG_VERSION_CODENAME"' , NG_VERSION . codename ) .
98
- gsub ( /^\s *['"]use strict['"];?\s *$/ , '' ) . # remove all file-specific strict mode flags
99
- gsub ( /'USE STRICT'/ , "'use strict'" ) # rename the placeholder in angular.prefix
100
-
101
- f . write ( content )
102
- f . write ( gen_css ( 'css/angular.css' , true ) )
103
- end
104
-
105
- %x(java -jar lib/closure-compiler/compiler.jar \
106
- --compilation_level SIMPLE_OPTIMIZATIONS \
107
- --language_in ECMASCRIPT5_STRICT \
108
- --js #{ path_to ( 'angular.js' ) } \
109
- --js_output_file #{ path_to ( 'angular.min.js' ) } )
69
+ concatFile ( 'angular.js' , [
70
+ 'src/angular.prefix' ,
71
+ files [ 'angularSrc' ] ,
72
+ 'src/angular.suffix' ,
73
+ ] , gen_css ( 'css/angular.css' , true ) )
110
74
111
75
FileUtils . cp_r 'src/ngLocale' , path_to ( 'i18n' )
112
76
113
- File . open ( path_to ( 'angular-loader.js' ) , 'w' ) do |f |
114
- concat = 'cat ' + [
77
+ concatFile ( 'angular-loader.js' , [
115
78
'src/loader.prefix' ,
116
79
'src/loader.js' ,
117
- 'src/loader.suffix' ] . flatten . join ( ' ' )
118
-
119
- content = %x{#{ concat } } .
120
- gsub ( '"NG_VERSION_FULL"' , NG_VERSION . full ) .
121
- gsub ( /^\s *['"]use strict['"];?\s *$/ , '' ) # remove all file-specific strict mode flags
122
-
123
- f . write ( content )
124
- end
125
-
126
- %x(java -jar lib/closure-compiler/compiler.jar \
127
- --compilation_level SIMPLE_OPTIMIZATIONS \
128
- --language_in ECMASCRIPT5_STRICT \
129
- --js #{ path_to ( 'angular-loader.js' ) } \
130
- --js_output_file #{ path_to ( 'angular-loader.min.js' ) } )
80
+ 'src/loader.suffix' ] )
81
+
82
+ FileUtils . cp 'src/ngMock/angular-mocks.js' , path_to ( 'angular-mocks.js' )
131
83
84
+
85
+ closureCompile ( 'angular.js' )
86
+ closureCompile ( 'angular-loader.js' )
132
87
133
88
end
134
89
@@ -153,11 +108,11 @@ task :package => [:clean, :compile, :docs] do
153
108
FileUtils . rm_r ( path_to ( 'pkg' ) , :force => true )
154
109
FileUtils . mkdir_p ( pkg_dir )
155
110
156
- [ 'src/ngMock/angular-mocks.js' ,
157
- path_to ( 'angular.js' ) ,
158
- path_to ( 'angular-loader.js' ) ,
111
+ [ path_to ( 'angular.js' ) ,
159
112
path_to ( 'angular.min.js' ) ,
113
+ path_to ( 'angular-loader.js' ) ,
160
114
path_to ( 'angular-loader.min.js' ) ,
115
+ path_to ( 'angular-mocks.js' ) ,
161
116
path_to ( 'angular-scenario.js' ) ,
162
117
path_to ( 'jstd-scenario-adapter.js' ) ,
163
118
path_to ( 'jstd-scenario-adapter-config.js' ) ,
336
291
def path_to ( filename )
337
292
return File . join ( BUILD_DIR , *filename )
338
293
end
294
+
295
+ def closureCompile ( filename )
296
+ puts "Compiling #{ filename } ..."
297
+ %x(java -jar lib/closure-compiler/compiler.jar \
298
+ --compilation_level SIMPLE_OPTIMIZATIONS \
299
+ --language_in ECMASCRIPT5_STRICT \
300
+ --js #{ path_to ( filename ) } \
301
+ --js_output_file #{ path_to ( filename . gsub ( /\. js$/ , '.min.js' ) ) } )
302
+ end
303
+
304
+ def concatFile ( filename , deps , footer = '' )
305
+ puts "Building #{ filename } ..."
306
+ File . open ( path_to ( filename ) , 'w' ) do |f |
307
+ concat = 'cat ' + deps . flatten . join ( ' ' )
308
+
309
+ content = %x{#{ concat } } .
310
+ gsub ( '"NG_VERSION_FULL"' , NG_VERSION . full ) .
311
+ gsub ( '"NG_VERSION_MAJOR"' , NG_VERSION . major ) .
312
+ gsub ( '"NG_VERSION_MINOR"' , NG_VERSION . minor ) .
313
+ gsub ( '"NG_VERSION_DOT"' , NG_VERSION . dot ) .
314
+ gsub ( '"NG_VERSION_CODENAME"' , NG_VERSION . codename ) .
315
+ gsub ( /^\s *['"]use strict['"];?\s *$/ , '' ) . # remove all file-specific strict mode flags
316
+ gsub ( /'USE STRICT'/ , "'use strict'" ) # rename the placeholder in angular.prefix
317
+
318
+ f . write ( content )
319
+ f . write ( footer )
320
+ end
321
+ end
322
+
0 commit comments