sprockets 3.7.2 → 4.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +2 -295
  3. data/README.md +21 -35
  4. data/bin/sprockets +11 -8
  5. data/lib/rake/sprocketstask.rb +2 -2
  6. data/lib/sprockets.rb +79 -34
  7. data/lib/sprockets/asset.rb +8 -21
  8. data/lib/sprockets/autoload.rb +3 -0
  9. data/lib/sprockets/autoload/babel.rb +7 -0
  10. data/lib/sprockets/autoload/jsminc.rb +7 -0
  11. data/lib/sprockets/autoload/sassc.rb +7 -0
  12. data/lib/sprockets/babel_processor.rb +58 -0
  13. data/lib/sprockets/base.rb +8 -8
  14. data/lib/sprockets/bower.rb +4 -2
  15. data/lib/sprockets/bundle.rb +1 -1
  16. data/lib/sprockets/cache.rb +2 -4
  17. data/lib/sprockets/closure_compressor.rb +1 -2
  18. data/lib/sprockets/coffee_script_processor.rb +9 -3
  19. data/lib/sprockets/compressing.rb +2 -2
  20. data/lib/sprockets/configuration.rb +1 -7
  21. data/lib/sprockets/context.rb +10 -18
  22. data/lib/sprockets/digest_utils.rb +40 -52
  23. data/lib/sprockets/directive_processor.rb +10 -13
  24. data/lib/sprockets/http_utils.rb +19 -4
  25. data/lib/sprockets/jsminc_compressor.rb +31 -0
  26. data/lib/sprockets/jst_processor.rb +10 -10
  27. data/lib/sprockets/loader.rb +34 -28
  28. data/lib/sprockets/manifest.rb +3 -35
  29. data/lib/sprockets/manifest_utils.rb +0 -2
  30. data/lib/sprockets/mime.rb +7 -42
  31. data/lib/sprockets/path_dependency_utils.rb +2 -11
  32. data/lib/sprockets/path_digest_utils.rb +1 -1
  33. data/lib/sprockets/path_utils.rb +43 -18
  34. data/lib/sprockets/preprocessors/default_source_map.rb +24 -0
  35. data/lib/sprockets/processing.rb +30 -61
  36. data/lib/sprockets/processor_utils.rb +27 -28
  37. data/lib/sprockets/resolve.rb +172 -92
  38. data/lib/sprockets/sass_cache_store.rb +1 -6
  39. data/lib/sprockets/sass_compressor.rb +14 -1
  40. data/lib/sprockets/sass_processor.rb +18 -8
  41. data/lib/sprockets/sassc_compressor.rb +30 -0
  42. data/lib/sprockets/sassc_processor.rb +68 -0
  43. data/lib/sprockets/server.rb +9 -20
  44. data/lib/sprockets/source_map_comment_processor.rb +29 -0
  45. data/lib/sprockets/source_map_processor.rb +40 -0
  46. data/lib/sprockets/source_map_utils.rb +345 -0
  47. data/lib/sprockets/transformers.rb +62 -35
  48. data/lib/sprockets/uglifier_compressor.rb +12 -5
  49. data/lib/sprockets/unloaded_asset.rb +12 -11
  50. data/lib/sprockets/uri_tar.rb +4 -2
  51. data/lib/sprockets/uri_utils.rb +5 -5
  52. data/lib/sprockets/utils.rb +30 -78
  53. data/lib/sprockets/version.rb +1 -1
  54. metadata +62 -20
  55. data/LICENSE +0 -21
  56. data/lib/sprockets/coffee_script_template.rb +0 -17
  57. data/lib/sprockets/deprecation.rb +0 -90
  58. data/lib/sprockets/eco_template.rb +0 -17
  59. data/lib/sprockets/ejs_template.rb +0 -17
  60. data/lib/sprockets/engines.rb +0 -92
  61. data/lib/sprockets/erb_template.rb +0 -11
  62. data/lib/sprockets/legacy.rb +0 -330
  63. data/lib/sprockets/legacy_proc_processor.rb +0 -35
  64. data/lib/sprockets/legacy_tilt_processor.rb +0 -29
  65. data/lib/sprockets/sass_template.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 46e0f0a150aa8333d2a1d2663167b6f20c1e77db067cea7b545f75927f770807
4
- data.tar.gz: 5acd5cb5c64e240dd8180e91f34620195fa1433e625ee48a132fdae58be71ba5
2
+ SHA1:
3
+ metadata.gz: 60c7b56c815bf217d4f5dfaeba611132c1b69964
4
+ data.tar.gz: 0ed9b0faa7b1606dc0cba718b3ec39afeb62255e
5
5
  SHA512:
6
- metadata.gz: 97a06eb2e0767903da7bcda387211d881f3b98d57269a8abed5045e277db5f133f381c4f8fd23fcccf45a4032c85309841abba13b9218a52b21121a5a9bfc02a
7
- data.tar.gz: 1d9c8d75bab64c366473226cc61806cd64c1951a67d90cc1220c1474e6a02cc5003b2dffb1b6324abefb7e7c8b292145635ac0bed6ae947a35393d67acd3c40e
6
+ metadata.gz: 6f297befe6ef41895b1b239741c9f705c52436f902963443c6bde3b68c67e89d3dfcfec3e132ce9aa21276ae6ac7e7759d7651d3d8f00e7d0f7d68445570202a
7
+ data.tar.gz: cf82702092f023a61057f9557cae0e9f2cdcacf0a0d9cd5619bdad116a984681bd5a1a9319aaaf2ca40109be6b31107ae49ec5bea7ab5a6822514f94304ca0fb
@@ -1,296 +1,3 @@
1
- **3.7.2** (June 19, 2018)
1
+ **Master**
2
2
 
3
- * Security release for [CVE-2018-3760](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-3760).
4
-
5
- **3.7.1** (December 19, 2016)
6
-
7
- * Ruby 2.4 support for Sprockets 3.
8
-
9
- **3.7.0** (July 21, 2016)
10
-
11
- * Deprecated interfaces now emit deprecation warnings #345
12
-
13
- **3.6.3** (July 1, 2016)
14
-
15
- * Faster asset lookup in large directories #336
16
- * Faster PathUtils.match_path_extname https://github.com/rails/sprockets/commit/697269cf81e5261fdd7072e32bd489403027fd7e
17
- * Fixed uglifier comment stripping #326
18
- * Error messages now show load path info #313
19
-
20
- **3.6.2** (June 21, 2016)
21
-
22
- * More performance improvements.
23
-
24
- **3.6.1** (June 17, 2016)
25
-
26
- * Some performance improvements.
27
-
28
- **3.6.0** (April 6, 2016)
29
-
30
- * Add `Manifest#find_sources` to return the source of the compiled assets.
31
- * Fix the list of compressable mime types.
32
- * Improve performance of the `FileStore` cache.
33
-
34
- **3.5.2** (December 8, 2015)
35
-
36
- * Fix JRuby bug with concurrent-ruby.
37
- * Fix disabling gzip generation in cached environments.
38
-
39
- **3.5.1** (December 5, 2015)
40
-
41
- * Fix gzip asset generation for assets already on disk.
42
-
43
- **3.5.0** (December 3, 2015)
44
-
45
- * Reintroduce Gzip file generation for non-binary assets.
46
-
47
- **3.4.1** (November 25, 2015)
48
-
49
- * PathUtils::Entries will no longer error on an empty directory.
50
-
51
- **3.4.0** (October 5, 2015)
52
-
53
- * Expose method to override the sass cache in the SassProcessor.
54
-
55
- **3.3.5** (September 25, 2015)
56
-
57
- * Fix bug related to absolute path being reintroduced into history cache #141.
58
-
59
- **3.3.4** (September 1, 2015)
60
-
61
- * Relative cache contents now work with windows.
62
-
63
- **3.3.3** (August 21, 2015)
64
-
65
- * Remove more absolute paths from cache contents.
66
-
67
- **3.3.2** (August 19, 2015)
68
-
69
- * Fix cache contents to use relative paths instead of absolute paths.
70
-
71
- **3.3.1** (August 15, 2015)
72
-
73
- * Fix legacy Tilt integration when locals is required argument.
74
-
75
- **3.3.0** (August 12, 2015)
76
-
77
- * Change internal cache key to use relative asset paths instead of absolute paths.
78
-
79
- **3.2.0** (June 2, 2015)
80
-
81
- * Updated SRI integrity to align with spec changes
82
- * Deprecated Manifest integrity attribute
83
- * Cleanup concatenating JS sources with newlines
84
-
85
- **3.1.0** (May 10, 2015)
86
-
87
- * Removed "index" logical path normalization. Asset#logical_path is always the
88
- full logical path to the index file.
89
- * Fixed static asset mtimes
90
- * Fix manifest cleanup by age
91
- * Removed redundant minifier level cache
92
- * Updated SRI format according to spec changes
93
-
94
- **3.0.3** (April 27, 2015)
95
-
96
- * Fix static asset mtime fallback
97
- * Only warn when specified asset version can not be loaded.
98
-
99
- **3.0.2** (April 22, 2015)
100
-
101
- * Ensure legacy Tilt handlers return String class data. Fixes issues with Haml
102
- Tilt handler.
103
- * Type check and improve error messages raised on bad processor returned results.
104
- * Improve error message for relative paths not under load path.
105
- * Changed HTML encoding fallback from ISO-8859-1 to default external.
106
- * Avoid falling back to 0 mtimes which may cause warnings with tar
107
-
108
- **3.0.1** (April 14, 2015)
109
-
110
- * Fixed `Context#depend_on` with paths outside the load path
111
-
112
- **3.0.0** (April 12, 2015)
113
-
114
- [Guide to upgrading from Sprockets 2.x to 3.x](https://github.com/rails/sprockets/blob/3.x/UPGRADING.md)
115
-
116
- * New processor API. Tilt interface is deprecated.
117
- * Improved file store caching backend.
118
- * MIME Types now accept charset custom charset detecters. Improves support for UTF-16/32 files.
119
- * Environment#version no longer affects asset digests. Only used for busting the asset cache.
120
- * Removed builtin support for LESS.
121
- * Removed `//= include` directive support.
122
- * Deprecated `BundledAsset#to_a`. Use `BundledAsset#included` to access debugging subcomponents.
123
- * Support circular dependencies. For parity with ES6 modules.
124
- * Manifest compilation will no longer generate .gz files by default. [Mixing
125
- Content-Encoding and ETags is just a bad
126
- idea](https://issues.apache.org/bugzilla/show_bug.cgi?id=39727)
127
- * Added linked or referenced assets. When an asset is compiled, any of its links will be compiled as well.
128
- * Introduce some limitations around enumerating all logical paths. 4.x will deprecate it and favor linked manifests for compliation.
129
- * Add Asset integrity attribute for Subresource Integrity
130
- * Default digest changed to SHA256. Configuring `digest_class` is deprecated.
131
- * Rename `Asset#digest` to `Asset#hexdigest`. `Asset#digest` is deprecated and will
132
- return a raw byte String in 4.x.
133
- * Added transitional compatibility flag to `Environment#resolve(path, compat: true)`. 2.x mode operates with `compat: true` and 4.x with `compat: false`
134
- * `manifest-abc123.json` renamed to `.sprockets-abc123.json`
135
-
136
- **2.12.3** (October 28, 2014)
137
-
138
- * Security: Fix directory traversal bug in development mode server.
139
-
140
- **2.12.2** (September 5, 2014)
141
-
142
- * Ensure internal asset lookups calls are still restricted to load paths within
143
- asset compiles. Though, you should not depend on internal asset resolves to be
144
- completely restricted for security reasons. Assets themselves should be
145
- considered full scripting environments with filesystem access.
146
-
147
- **2.12.1** (April 17, 2014)
148
-
149
- * Fix making manifest target directory when its different than the output directory.
150
-
151
- **2.12.0** (March 13, 2014)
152
-
153
- * Avoid context reference in SassImporter hack so its Marshallable. Fixes
154
- issues with Sass 3.3.x.
155
-
156
- **2.11.0** (February 19, 2014)
157
-
158
- * Cache store must now be an LRU implementation.
159
- * Default digest changed to SHA1. To continue using MD5.
160
- `env.digest_class = Digest::MD5`.
161
-
162
- **2.10.0** (May 24, 2013)
163
-
164
- * Support for `bower.json`
165
-
166
- **2.9.3** (April 20, 2013)
167
-
168
- * Fixed sass caching bug
169
-
170
- **2.9.2** (April 8, 2013)
171
-
172
- * Improve file freshness check performance
173
- * Directive processor encoding fixes
174
-
175
- **2.9.1** (April 6, 2013)
176
-
177
- * Support for Uglifier 2.x
178
-
179
- **2.9.0** (February 25, 2013)
180
-
181
- * Write out gzipped variants of bundled assets.
182
-
183
- **2.8.2** (December 10, 2012)
184
-
185
- * Fixed top level Sass constant references
186
- * Fixed manifest logger when environment is disabled
187
-
188
- **2.8.1** (October 31, 2012)
189
-
190
- * Fixed Sass importer bug
191
-
192
- **2.8.0** (October 16, 2012)
193
-
194
- * Allow manifest location to be separated from output directory
195
- * Pass logical path and absolute path to each_logical_path iterator
196
-
197
- **2.7.0** (October 10, 2012)
198
-
199
- * Added --css-compressor and --js-compressor command line flags
200
- * Added css/js compressor shorthand
201
- * Change default manifest.json filename to be a randomized manifest-16HEXBYTES.json
202
- * Allow nil environment to be passed to manifest
203
- * Allow manifest instance to be set on rake task
204
-
205
- **2.6.0** (September 19, 2012)
206
-
207
- * Added bower component.json require support
208
-
209
- **2.5.0** (September 4, 2012)
210
-
211
- * Fixed Ruby 2.0 RegExp warning
212
- * Provide stubbed implementation of context *_path helpers
213
- * Add SassCompressor
214
-
215
- **2.4.5** (July 10, 2012)
216
-
217
- * Tweaked some logger levels
218
-
219
- **2.4.4** (July 2, 2012)
220
-
221
- * Canonicalize logical path extensions
222
- * Check absolute paths passed to depend_on
223
-
224
- **2.4.3** (May 16, 2012)
225
-
226
- * Exposed :sprockets in sass options
227
- * Include dependency paths in asset mtime
228
-
229
- **2.4.2** (May 7, 2012)
230
-
231
- * Fixed MultiJson feature detect
232
-
233
- **2.4.1** (April 26, 2012)
234
-
235
- * Fixed MultiJson API change
236
- * Fixed gzip mtime
237
-
238
- **2.4.0** (March 27, 2012)
239
-
240
- * Added global path registry
241
- * Added global processor registry
242
-
243
- **2.3.2** (March 26, 2012)
244
-
245
- * Fix Context#logical_path with dots
246
-
247
- **2.3.1** (February 11, 2012)
248
-
249
- * Added bytesize to manifest
250
- * Added Asset#bytesize alias
251
- * Security: Check path for forbidden access after unescaping
252
-
253
- **2.3.0** (January 16, 2012)
254
-
255
- * Added special Sass importer that automatically tracks any `@import`ed files.
256
-
257
- **2.2.0** (January 10, 2012)
258
-
259
- * Added `sprockets` command line utility.
260
- * Added rake/sprocketstask.
261
- * Added json manifest log of compiled assets.
262
- * Added `stub` directive that allows you to exclude files from the bundle.
263
- * Added per environment external encoding (Environment#default_external_encoding). Defaults to UTF-8. Fixes issues where LANG is not set correctly and Rubys default external is set to ASCII.
264
-
265
- **2.1.2** (November 20, 2011)
266
-
267
- * Disabled If-Modified-Since server checks. Fixes some browser caching issues when serving the asset body only. If-None-Match caching is sufficient.
268
-
269
- **2.1.1** (November 18, 2011)
270
-
271
- * Fix windows absolute path check bug.
272
-
273
- **2.1.0** (November 11, 2011)
274
-
275
- * Directive comment lines are now turned into empty lines instead of removed. This way line numbers in
276
- CoffeeScript syntax errors are correct.
277
- * Performance and caching bug fixes.
278
-
279
- **2.0.3** (October 17, 2011)
280
-
281
- * Detect format extensions from right to left.
282
- * Make JST namespace configurable.
283
-
284
- **2.0.2** (October 4, 2011)
285
-
286
- * Fixed loading stale cache from bundler gems.
287
-
288
- **2.0.1** (September 30, 2011)
289
-
290
- * Fixed bug with fingerprinting file names with multiple dots.
291
- * Decode URIs as default internal.
292
- * Fix symlinked asset directories.
293
-
294
- **2.0.0** (August 29, 2011)
295
-
296
- * Initial public release.
3
+ Please check the 3.x branch for previous changes https://github.com/rails/sprockets/blob/3.x/CHANGELOG.md.
data/README.md CHANGED
@@ -20,21 +20,21 @@ Or include it in your project's `Gemfile` with Bundler:
20
20
  gem 'sprockets', '~> 3.0'
21
21
  ```
22
22
 
23
- ## Using sprockets
23
+ ## Using Sprockets
24
24
 
25
- For most people interested in using sprockets you will want to see [End User Asset Generation](guides/end_user_asset_generation.md) guide. This contains information about sprocket's directive syntax, and default processing behavior.
25
+ For most people interested in using Sprockets you will want to see [End User Asset Generation](guides/end_user_asset_generation.md) guide. This contains information about sprocket's directive syntax, and default processing behavior.
26
26
 
27
- If you are a framework developer that is using sprockets, see [Building an Asset Processing Framework](guides/building_an_asset_processing_framework.md).
27
+ If you are a framework developer that is using Sprockets, see [Building an Asset Processing Framework](guides/building_an_asset_processing_framework.md).
28
28
 
29
- If you are a library developer who is extending the functionality of sprockets, see [Extending Sprockets](guides/extending_sprockets.md).
29
+ If you are a library developer who is extending the functionality of Sprockets, see [Extending Sprockets](guides/extending_sprockets.md).
30
30
 
31
- Below is a disjointed mix of documentation for all three of these roles. Eventually they will be moved to an appropriate guide, for now the recommended way to consume documentation is to view the appropriate guide first and then supplement with docs from the README.
31
+ Below is a disjointed mix of documentation for all three of these roles. Eventually they will be moved to an appropriate guide, for now the recommended way to consume this documentation is to view the appropriate guide first and then supplement with docs from the README.
32
32
 
33
33
  ## Behavior
34
34
 
35
35
  ### Index files are proxies for folders
36
36
 
37
- In sprockets index files such as `index.js` or `index.css` files inside of a folder will generate a file with the folder's name. So if you have a `foo/index.js` file it will compile down to `foo.js`. This is similar to NPM's behavior of using [folders as modules](https://nodejs.org/api/modules.html#modules_folders_as_modules). It is also somewhat similar to the way that a file in `public/my_folder/index.html` can be reached by a request to `/my_folder`. This means that you cannot directly use an index file. For example this would not work:
37
+ In Sprockets index files such as `index.js` or `index.css` files inside of a folder will generate a file with the folder's name. So if you have a `foo/index.js` file it will compile down to `foo.js`. This is similar to Node.js's behavior of using [folders as modules](https://nodejs.org/api/modules.html#modules_folders_as_modules). It is also somewhat similar to the way that a file in `public/my_folder/index.html` can be reached by a request to `/my_folder`. This means that you cannot directly use an index file. For example this would not work:
38
38
 
39
39
  ```
40
40
  <%= asset_path("foo/index.js") %>
@@ -46,13 +46,13 @@ Instead you would need to use:
46
46
  <%= asset_path("foo.js") %>
47
47
  ```
48
48
 
49
- Why would you want to use this behavior? It is common behavior where you might want to include an entire directory of files in a top level javascript. You can do this in sprockets using `require_tree .`
49
+ Why would you want to use this behavior? It is common behavior where you might want to include an entire directory of files in a top level javascript. You can do this in Sprockets using `require_tree .`
50
50
 
51
51
  ```
52
52
  //= require_tree .
53
53
  ```
54
54
 
55
- This has the problem that files are required alphabetically. If your directory has `jquery-ui.js` and `jquery.min.js` then sprockets will require `jquery-ui.js` before `jquery` is required which won't work (because jquery-ui depends on jquery). Previously the only way to get the correct ordering would be to rename your files, something like `0-jquery-ui.js`. Instead of doing that you can use an index file.
55
+ This has the problem that files are required alphabetically. If your directory has `jquery-ui.js` and `jquery.min.js` then Sprockets will require `jquery-ui.js` before `jquery` is required which won't work (because jquery-ui depends on jquery). Previously the only way to get the correct ordering would be to rename your files, something like `0-jquery-ui.js`. Instead of doing that you can use an index file.
56
56
 
57
57
  For example, if you have an `application.js` and want all the files in the `foo/` folder you could do this:
58
58
 
@@ -191,9 +191,9 @@ get its length in bytes, `mtime` to query its last-modified time, and
191
191
 
192
192
  ## Using Processors
193
193
 
194
- Asset source files can be written in another format, like SCSS or
195
- CoffeeScript, and automatically compiled to CSS or JavaScript by
196
- Sprockets. Processors that convert a file from one format to another are called *transformers*.
194
+ Asset source files can be written in another format, like SCSS or CoffeeScript,
195
+ and automatically compiled to CSS or JavaScript by Sprockets. Processors that
196
+ convert a file from one format to another are called *transformers*.
197
197
 
198
198
  ### Minifying Assets
199
199
 
@@ -204,6 +204,9 @@ environment.js_compressor = :uglify
204
204
  environment.css_compressor = :scss
205
205
  ```
206
206
 
207
+ If you are using Sprockets directly with Rack app, don't forget to add
208
+ `uglifier` and `sass` gems to your Gemfile when using above options.
209
+
207
210
  ### Styling with Sass and SCSS
208
211
 
209
212
  [Sass](http://sass-lang.com/) is a language that compiles to CSS and
@@ -219,7 +222,7 @@ new SCSS syntax, use the extension `.scss`.
219
222
 
220
223
  ### Scripting with CoffeeScript
221
224
 
222
- [CoffeeScript](http://jashkenas.github.com/coffee-script/) is a
225
+ [CoffeeScript](http://jashkenas.github.io/coffeescript/) is a
223
226
  language that compiles to the "good parts" of JavaScript, featuring a
224
227
  cleaner syntax with array comprehensions, classes, and function
225
228
  binding.
@@ -414,12 +417,11 @@ recursively reading the file and following the directives found. This is automat
414
417
 
415
418
  #### The `stub` Directive
416
419
 
417
- `stub` *path* allows dependency to be excluded from the asset bundle.
420
+ `stub` *path* excludes that asset and its dependencies from the asset bundle.
418
421
  The *path* must be a valid asset and may or may not already be part
419
422
  of the bundle. `stub` should only be used at the top level bundle, not
420
423
  within any subdependencies.
421
424
 
422
-
423
425
  ## Processor Interface
424
426
 
425
427
  Sprockets 2.x was originally design around [Tilt](https://github.com/rtomayko/tilt)'s engine interface. However, starting with 3.x, a new interface has been introduced deprecating Tilt.
@@ -478,32 +480,16 @@ def self.call(input)
478
480
  end
479
481
  ```
480
482
 
483
+ ## Contributing to Sprockets
481
484
 
482
- ## Development
483
-
484
- ### Contributing
485
-
486
- The Sprockets source code is [hosted on
487
- GitHub](https://github.com/rails/sprockets). You can check out a
488
- copy of the latest code using Git:
485
+ Sprockets is the work of hundreds of contributors. You're encouraged to submit pull requests, propose
486
+ features and discuss issues.
489
487
 
490
- $ git clone https://github.com/rails/sprockets
491
-
492
- If you've found a bug or have a question, please open an issue on the
493
- [Sprockets issue
494
- tracker](https://github.com/rails/sprockets/issues). Or, clone
495
- the Sprockets repository, write a failing test case, fix the bug and
496
- submit a pull request.
488
+ See [CONTRIBUTING](CONTRIBUTING.md).
497
489
 
498
490
  ### Version History
499
491
 
500
492
  Please see the [CHANGELOG](https://github.com/rails/sprockets/tree/master/CHANGELOG.md)
501
493
 
502
494
  ## License
503
-
504
- Copyright &copy; 2014 Sam Stephenson <<sstephenson@gmail.com>>
505
-
506
- Copyright &copy; 2014 Joshua Peek <<josh@joshpeek.com>>
507
-
508
- Sprockets is distributed under an MIT-style license. See LICENSE for
509
- details.
495
+ Sprockets is released under the [MIT License](MIT-LICENSE).
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- $VERBOSE = nil
3
2
 
4
3
  require 'sprockets'
5
4
  require 'optparse'
@@ -12,7 +11,7 @@ unless ARGV.delete("--noenv")
12
11
  end
13
12
  end
14
13
 
15
- filenames = []
14
+ paths = []
16
15
  environment = Sprockets::Environment.new(Dir.pwd)
17
16
  manifest = nil
18
17
 
@@ -52,6 +51,10 @@ OptionParser.new do |opts|
52
51
  opts.on("--noenv", "Disables .sprocketsrc file") do
53
52
  end
54
53
 
54
+ opts.on("--cache=DIRECTORY", "Enables the FileStore cache using the specified directory") do |directory|
55
+ environment.cache = Sprockets::Cache::FileStore.new(directory)
56
+ end
57
+
55
58
  opts.on_tail("-h", "--help", "Shows this help message") do
56
59
  opts.show_usage
57
60
  end
@@ -64,8 +67,8 @@ OptionParser.new do |opts|
64
67
  opts.show_usage if ARGV.empty?
65
68
 
66
69
  begin
67
- opts.order(ARGV) do |filename|
68
- filenames << File.expand_path(filename)
70
+ opts.order(ARGV) do |path|
71
+ paths << path
69
72
  end
70
73
  rescue OptionParser::ParseError => e
71
74
  opts.warn e.message
@@ -75,14 +78,14 @@ end
75
78
 
76
79
  if environment.paths.empty?
77
80
  warn "No load paths given"
78
- warn "Usage: sprockets -Ijavascripts/ filename"
81
+ warn "Usage: sprockets -Ijavascripts/ path"
79
82
  exit 1
80
83
  end
81
84
 
82
85
  if manifest
83
- manifest.compile(filenames)
84
- elsif filenames.length == 1
85
- puts environment.find_asset(filenames.first).to_s
86
+ manifest.compile(paths)
87
+ elsif paths.length == 1
88
+ puts environment.find_asset(paths.first).to_s
86
89
  else
87
90
  warn "Only one file can be compiled to stdout at a time"
88
91
  exit 1