less 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (265) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +4 -0
  3. data/Gemfile +1 -1
  4. data/less.gemspec +1 -1
  5. data/lib/less/defaults.rb +3 -3
  6. data/lib/less/java_script/v8_context.rb +1 -1
  7. data/lib/less/js/.gitattributes +3 -2
  8. data/lib/less/js/.gitignore +18 -2
  9. data/lib/less/js/.jshintrc +11 -0
  10. data/lib/less/js/CHANGELOG.md +87 -2
  11. data/lib/less/js/CONTRIBUTING.md +4 -3
  12. data/lib/less/js/Gruntfile.js +290 -0
  13. data/lib/less/js/README.md +342 -12
  14. data/lib/less/js/benchmark/benchmark.less +194 -194
  15. data/lib/less/js/benchmark/less-benchmark.js +9 -10
  16. data/lib/less/js/bin/lessc +154 -12
  17. data/lib/less/js/bower.json +18 -0
  18. data/lib/less/js/build.gradle +347 -0
  19. data/lib/less/js/build/README.md +350 -0
  20. data/lib/less/js/build/browser-header.js +4 -0
  21. data/lib/less/js/build/build.yml +160 -0
  22. data/lib/less/js/build/require-rhino.js +7 -2
  23. data/lib/less/js/build/rhino-header.js +4 -0
  24. data/lib/less/js/build/rhino-modules.js +131 -0
  25. data/lib/less/js/build/tasks/.gitkeep +1 -0
  26. data/lib/less/js/dist/less-1.5.0.js +6914 -0
  27. data/lib/less/js/dist/less-1.5.0.min.js +13 -0
  28. data/lib/less/js/dist/less-1.5.1.js +6941 -0
  29. data/lib/less/js/dist/less-1.5.1.min.js +13 -0
  30. data/lib/less/js/dist/less-1.6.0.js +7485 -0
  31. data/lib/less/js/dist/less-1.6.0.min.js +16 -0
  32. data/lib/less/js/dist/less-1.6.1.js +7513 -0
  33. data/lib/less/js/dist/less-1.6.1.min.js +16 -0
  34. data/lib/less/js/dist/less-1.6.2.js +7624 -0
  35. data/lib/less/js/dist/less-1.6.2.min.js +16 -0
  36. data/lib/less/js/dist/less-rhino-1.5.1.js +6831 -0
  37. data/lib/less/js/dist/less-rhino-1.6.2.js +9017 -0
  38. data/lib/less/js/dist/lessc-rhino-1.6.2.js +449 -0
  39. data/lib/less/js/gradle/wrapper/gradle-wrapper.jar +0 -0
  40. data/lib/less/js/gradle/wrapper/gradle-wrapper.properties +6 -0
  41. data/lib/less/js/gradlew +164 -0
  42. data/lib/less/js/gradlew.bat +90 -0
  43. data/lib/less/js/lib/less/browser.js +482 -367
  44. data/lib/less/js/lib/less/colors.js +0 -1
  45. data/lib/less/js/lib/less/encoder.js +4 -0
  46. data/lib/less/js/lib/less/env.js +50 -19
  47. data/lib/less/js/lib/less/extend-visitor.js +66 -41
  48. data/lib/less/js/lib/less/functions.js +309 -104
  49. data/lib/less/js/lib/less/import-visitor.js +21 -10
  50. data/lib/less/js/lib/less/index.js +90 -68
  51. data/lib/less/js/lib/less/join-selector-visitor.js +11 -4
  52. data/lib/less/js/lib/less/lessc_helper.js +56 -45
  53. data/lib/less/js/lib/less/parser.js +830 -460
  54. data/lib/less/js/lib/less/rhino.js +380 -58
  55. data/lib/less/js/lib/less/source-map-output.js +141 -0
  56. data/lib/less/js/lib/less/to-css-visitor.js +215 -0
  57. data/lib/less/js/lib/less/tree.js +57 -5
  58. data/lib/less/js/lib/less/tree/alpha.js +13 -5
  59. data/lib/less/js/lib/less/tree/anonymous.js +11 -5
  60. data/lib/less/js/lib/less/tree/assignment.js +11 -5
  61. data/lib/less/js/lib/less/tree/call.js +19 -8
  62. data/lib/less/js/lib/less/tree/color.js +59 -36
  63. data/lib/less/js/lib/less/tree/comment.js +17 -4
  64. data/lib/less/js/lib/less/tree/condition.js +3 -3
  65. data/lib/less/js/lib/less/tree/dimension.js +161 -153
  66. data/lib/less/js/lib/less/tree/directive.js +39 -18
  67. data/lib/less/js/lib/less/tree/element.js +41 -18
  68. data/lib/less/js/lib/less/tree/expression.js +11 -5
  69. data/lib/less/js/lib/less/tree/extend.js +11 -1
  70. data/lib/less/js/lib/less/tree/import.js +34 -20
  71. data/lib/less/js/lib/less/tree/javascript.js +16 -10
  72. data/lib/less/js/lib/less/tree/keyword.js +5 -2
  73. data/lib/less/js/lib/less/tree/media.js +39 -22
  74. data/lib/less/js/lib/less/tree/mixin.js +135 -56
  75. data/lib/less/js/lib/less/tree/negative.js +4 -2
  76. data/lib/less/js/lib/less/tree/operation.js +17 -12
  77. data/lib/less/js/lib/less/tree/paren.js +5 -2
  78. data/lib/less/js/lib/less/tree/quoted.js +9 -6
  79. data/lib/less/js/lib/less/tree/rule.js +39 -21
  80. data/lib/less/js/lib/less/tree/ruleset.js +229 -145
  81. data/lib/less/js/lib/less/tree/selector.js +101 -34
  82. data/lib/less/js/lib/less/tree/unicode-descriptor.js +4 -3
  83. data/lib/less/js/lib/less/tree/url.js +33 -11
  84. data/lib/less/js/lib/less/tree/value.js +13 -6
  85. data/lib/less/js/lib/less/tree/variable.js +13 -8
  86. data/lib/less/js/lib/less/visitor.js +117 -25
  87. data/lib/less/js/lib/source-map/source-map-0.1.31.js +1933 -0
  88. data/lib/less/js/lib/source-map/source-map-footer.js +4 -0
  89. data/lib/less/js/lib/source-map/source-map-header.js +3 -0
  90. data/lib/less/js/package.json +30 -15
  91. data/lib/less/js/test/browser/common.js +131 -56
  92. data/lib/less/js/test/browser/css/global-vars/simple.css +3 -0
  93. data/lib/less/js/test/browser/css/modify-vars/simple.css +8 -0
  94. data/lib/less/js/test/browser/css/relative-urls/urls.css +8 -9
  95. data/lib/less/js/test/browser/css/rootpath-relative/urls.css +0 -1
  96. data/lib/less/js/test/browser/css/rootpath/urls.css +0 -1
  97. data/lib/less/js/test/browser/css/urls.css +18 -14
  98. data/lib/less/js/test/browser/es5.js +27 -0
  99. data/lib/less/js/test/{less/errors/color-operation-error.less → browser/less/console-errors/test-error.less} +0 -0
  100. data/lib/less/js/test/browser/less/console-errors/test-error.txt +2 -0
  101. data/lib/less/js/test/browser/less/global-vars/simple.less +3 -0
  102. data/lib/less/js/test/browser/less/modify-vars/imports/simple2.less +4 -0
  103. data/lib/less/js/test/browser/less/modify-vars/simple.less +8 -0
  104. data/lib/less/js/test/browser/less/relative-urls/urls.less +1 -1
  105. data/lib/less/js/test/browser/less/rootpath-relative/urls.less +1 -1
  106. data/lib/less/js/test/browser/less/rootpath/urls.less +1 -1
  107. data/lib/less/js/test/browser/less/urls.less +9 -1
  108. data/lib/less/js/test/browser/phantom-runner.js +112 -103
  109. data/lib/less/js/test/browser/runner-browser-options.js +42 -0
  110. data/lib/less/js/test/browser/{runner-browser.js → runner-browser-spec.js} +7 -2
  111. data/lib/less/js/test/browser/runner-console-errors.js +5 -0
  112. data/lib/less/js/test/browser/runner-errors-options.js +5 -0
  113. data/lib/less/js/test/browser/runner-errors-spec.js +4 -0
  114. data/lib/less/js/test/browser/runner-global-vars-options.js +4 -0
  115. data/lib/less/js/test/browser/runner-global-vars-spec.js +3 -0
  116. data/lib/less/js/test/browser/runner-legacy-options.js +4 -0
  117. data/lib/less/js/test/browser/{runner-legacy.js → runner-legacy-spec.js} +1 -4
  118. data/lib/less/js/test/browser/runner-main-options.js +15 -0
  119. data/lib/less/js/test/browser/runner-main-spec.js +3 -0
  120. data/lib/less/js/test/browser/runner-modify-vars-options.js +2 -0
  121. data/lib/less/js/test/browser/runner-modify-vars-spec.js +43 -0
  122. data/lib/less/js/test/browser/runner-no-js-errors-options.js +4 -0
  123. data/lib/less/js/test/browser/runner-no-js-errors-spec.js +4 -0
  124. data/lib/less/js/test/browser/runner-production-options.js +3 -0
  125. data/lib/less/js/test/browser/{runner-production.js → runner-production-spec.js} +1 -3
  126. data/lib/less/js/test/browser/runner-relative-urls-options.js +3 -0
  127. data/lib/less/js/test/browser/{runner-relative-urls.js → runner-relative-urls-spec.js} +1 -2
  128. data/lib/less/js/test/browser/runner-rootpath-options.js +3 -0
  129. data/lib/less/js/test/browser/runner-rootpath-relative-options.js +4 -0
  130. data/lib/less/js/test/browser/{runner-rootpath-relative.js → runner-rootpath-relative-spec.js} +1 -3
  131. data/lib/less/js/test/browser/{runner-rootpath.js → runner-rootpath-spec.js} +1 -2
  132. data/lib/less/js/test/browser/test-runner-template.tmpl +47 -0
  133. data/lib/less/js/test/css/colors.css +7 -0
  134. data/lib/less/js/test/css/comments.css +9 -4
  135. data/lib/less/js/test/css/compression/compression.css +3 -2
  136. data/lib/less/js/test/css/css-3.css +17 -5
  137. data/lib/less/js/test/css/css-guards.css +37 -0
  138. data/lib/less/js/test/css/debug/linenumbers-all.css +6 -0
  139. data/lib/less/js/test/css/debug/linenumbers-comments.css +5 -0
  140. data/lib/less/js/test/css/debug/linenumbers-mediaquery.css +5 -0
  141. data/lib/less/js/test/css/empty.css +0 -0
  142. data/lib/less/js/test/css/extend-chaining.css +9 -0
  143. data/lib/less/js/test/css/extend-selector.css +10 -2
  144. data/lib/less/js/test/css/extract-and-length.css +133 -0
  145. data/lib/less/js/test/css/functions.css +23 -10
  146. data/lib/less/js/test/css/globalVars/extended.css +12 -0
  147. data/lib/less/js/test/css/globalVars/simple.css +6 -0
  148. data/lib/less/js/test/css/import-inline.css +5 -0
  149. data/lib/less/js/test/css/import-once.css +12 -0
  150. data/lib/less/js/test/css/import-reference.css +49 -0
  151. data/lib/less/js/test/css/import.css +0 -2
  152. data/lib/less/js/test/css/media.css +21 -5
  153. data/lib/less/js/test/css/merge.css +26 -0
  154. data/lib/less/js/test/css/mixins-guards-default-func.css +129 -0
  155. data/lib/less/js/test/css/mixins-guards.css +6 -0
  156. data/lib/less/js/test/css/mixins-important.css +7 -0
  157. data/lib/less/js/test/css/mixins-interpolated.css +39 -0
  158. data/lib/less/js/test/css/mixins.css +20 -0
  159. data/lib/less/js/test/css/modifyVars/extended.css +9 -0
  160. data/lib/less/js/test/css/no-output.css +0 -0
  161. data/lib/less/js/test/css/parens.css +3 -0
  162. data/lib/less/js/test/css/property-name-interp.css +20 -0
  163. data/lib/less/js/test/css/selectors.css +12 -0
  164. data/lib/less/js/test/css/static-urls/urls.css +7 -4
  165. data/lib/less/js/test/css/strings.css +3 -0
  166. data/lib/less/js/test/css/url-args/urls.css +56 -0
  167. data/lib/less/js/test/css/urls.css +21 -9
  168. data/lib/less/js/test/index.js +45 -0
  169. data/lib/less/js/test/less-test.js +234 -191
  170. data/lib/less/js/test/less/colors.less +6 -0
  171. data/lib/less/js/test/less/comments.less +7 -1
  172. data/lib/less/js/test/less/compression/compression.less +21 -1
  173. data/lib/less/js/test/less/css-3.less +12 -0
  174. data/lib/less/js/test/less/css-guards.less +99 -0
  175. data/lib/less/js/test/less/debug/linenumbers.less +11 -1
  176. data/lib/less/js/test/less/empty.less +0 -0
  177. data/lib/less/js/test/less/errors/add-mixed-units.txt +4 -2
  178. data/lib/less/js/test/less/errors/add-mixed-units2.txt +4 -2
  179. data/lib/less/js/test/less/errors/color-func-invalid-color.less +3 -0
  180. data/lib/less/js/test/less/errors/color-func-invalid-color.txt +4 -0
  181. data/lib/less/js/test/less/errors/css-guard-default-func.less +4 -0
  182. data/lib/less/js/test/less/errors/css-guard-default-func.txt +4 -0
  183. data/lib/less/js/test/less/errors/import-subfolder2.txt +4 -2
  184. data/lib/less/js/test/less/errors/javascript-undefined-var.less +3 -0
  185. data/lib/less/js/test/less/errors/javascript-undefined-var.txt +4 -0
  186. data/lib/less/js/test/less/errors/mixins-guards-default-func-1.less +9 -0
  187. data/lib/less/js/test/less/errors/mixins-guards-default-func-1.txt +4 -0
  188. data/lib/less/js/test/less/errors/mixins-guards-default-func-2.less +9 -0
  189. data/lib/less/js/test/less/errors/mixins-guards-default-func-2.txt +4 -0
  190. data/lib/less/js/test/less/errors/mixins-guards-default-func-3.less +9 -0
  191. data/lib/less/js/test/less/errors/mixins-guards-default-func-3.txt +4 -0
  192. data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors.less +4 -0
  193. data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors.txt +4 -0
  194. data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors2.less +4 -0
  195. data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors2.txt +4 -0
  196. data/lib/less/js/test/less/errors/parse-error-curly-bracket.less +4 -1
  197. data/lib/less/js/test/less/errors/parse-error-curly-bracket.txt +4 -2
  198. data/lib/less/js/test/less/errors/parse-error-extra-parens.less +5 -0
  199. data/lib/less/js/test/less/errors/parse-error-extra-parens.txt +3 -0
  200. data/lib/less/js/test/less/errors/parse-error-missing-bracket.txt +2 -2
  201. data/lib/less/js/test/less/errors/parse-error-missing-parens.less +5 -0
  202. data/lib/less/js/test/less/errors/parse-error-missing-parens.txt +3 -0
  203. data/lib/less/js/test/less/errors/property-asterisk-only-name.less +3 -0
  204. data/lib/less/js/test/less/errors/property-asterisk-only-name.txt +4 -0
  205. data/lib/less/js/test/less/errors/property-interp-not-defined.less +1 -0
  206. data/lib/less/js/test/less/errors/property-interp-not-defined.txt +2 -0
  207. data/lib/less/js/test/less/errors/svg-gradient1.less +3 -0
  208. data/lib/less/js/test/less/errors/svg-gradient1.txt +4 -0
  209. data/lib/less/js/test/less/errors/svg-gradient2.less +3 -0
  210. data/lib/less/js/test/less/errors/svg-gradient2.txt +4 -0
  211. data/lib/less/js/test/less/errors/svg-gradient3.less +3 -0
  212. data/lib/less/js/test/less/errors/svg-gradient3.txt +4 -0
  213. data/lib/less/js/test/less/errors/unit-function.less +3 -0
  214. data/lib/less/js/test/less/errors/unit-function.txt +4 -0
  215. data/lib/less/js/test/less/extend-chaining.less +12 -0
  216. data/lib/less/js/test/less/extend-selector.less +15 -0
  217. data/lib/less/js/test/less/extract-and-length.less +133 -0
  218. data/lib/less/js/test/less/functions.less +15 -2
  219. data/lib/less/js/test/less/globalVars/extended.json +5 -0
  220. data/lib/less/js/test/less/globalVars/extended.less +10 -0
  221. data/lib/less/js/test/less/globalVars/simple.json +3 -0
  222. data/lib/less/js/test/less/globalVars/simple.less +3 -0
  223. data/lib/less/js/test/less/import-inline.less +2 -0
  224. data/lib/less/js/test/less/import-once.less +2 -0
  225. data/lib/less/js/test/less/import-reference.less +18 -0
  226. data/lib/less/js/test/less/import/import-and-relative-paths-test.less +11 -0
  227. data/lib/less/js/test/less/import/import-reference.less +43 -0
  228. data/lib/less/js/test/less/import/import-test-f.less +5 -0
  229. data/lib/less/js/test/less/import/invalid-css.less +1 -0
  230. data/lib/less/js/test/less/media.less +25 -1
  231. data/lib/less/js/test/less/merge.less +59 -0
  232. data/lib/less/js/test/less/mixins-args.less +10 -0
  233. data/lib/less/js/test/less/mixins-guards-default-func.less +195 -0
  234. data/lib/less/js/test/less/mixins-guards.less +16 -0
  235. data/lib/less/js/test/less/mixins-important.less +4 -1
  236. data/lib/less/js/test/less/mixins-interpolated.less +69 -0
  237. data/lib/less/js/test/less/mixins.less +27 -0
  238. data/lib/less/js/test/less/modifyVars/extended.json +5 -0
  239. data/lib/less/js/test/less/modifyVars/extended.less +11 -0
  240. data/lib/less/js/test/less/no-js-errors/no-js-errors.less +3 -0
  241. data/lib/less/js/test/less/no-js-errors/no-js-errors.txt +4 -0
  242. data/lib/less/js/test/less/no-output.less +2 -0
  243. data/lib/less/js/test/less/parens.less +4 -0
  244. data/lib/less/js/test/less/property-name-interp.less +53 -0
  245. data/lib/less/js/test/less/selectors.less +13 -0
  246. data/lib/less/js/test/less/sourcemaps/basic.json +3 -0
  247. data/lib/less/js/test/less/sourcemaps/basic.less +27 -0
  248. data/lib/less/js/test/less/sourcemaps/imported.css +7 -0
  249. data/lib/less/js/test/less/strings.less +6 -0
  250. data/lib/less/js/test/less/url-args/urls.less +63 -0
  251. data/lib/less/js/test/less/urls.less +15 -0
  252. data/lib/less/js/test/rhino/test-header.js +15 -0
  253. data/lib/less/js/test/sourcemaps/basic.json +1 -0
  254. data/lib/less/js/test/sourcemaps/index.html +17 -0
  255. data/lib/less/loader.rb +48 -40
  256. data/lib/less/version.rb +1 -1
  257. data/spec/less/parser_spec.rb +15 -15
  258. metadata +146 -40
  259. data/lib/less/js/Makefile +0 -102
  260. data/lib/less/js/build/header.js +0 -9
  261. data/lib/less/js/test/browser-test-prepare.js +0 -46
  262. data/lib/less/js/test/browser/runner-errors.js +0 -5
  263. data/lib/less/js/test/browser/runner-main.js +0 -15
  264. data/lib/less/js/test/browser/template.htm +0 -10
  265. data/lib/less/js/test/less/errors/color-operation-error.txt +0 -2
@@ -10,33 +10,32 @@ if (process.argv[2]) { file = path.join(process.cwd(), process.argv[2]) }
10
10
  fs.readFile(file, 'utf8', function (e, data) {
11
11
  var tree, css, start, end, total;
12
12
 
13
- sys.puts("Benchmarking...\n", path.basename(file) + " (" +
13
+ console.log("Benchmarking...\n", path.basename(file) + " (" +
14
14
  parseInt(data.length / 1024) + " KB)", "");
15
15
 
16
16
  start = new(Date);
17
17
 
18
18
  new(less.Parser)({ optimization: 2 }).parse(data, function (err, tree) {
19
- end = new(Date);
19
+ end = new Date();
20
20
 
21
21
  total = end - start;
22
22
 
23
- sys.puts("Parsing: " +
23
+ console.log("Parsing: " +
24
24
  total + " ms (" +
25
- parseInt(1000 / total *
26
- data.length / 1024) + " KB\/s)");
25
+ Number(1000 / total * data.length / 1024) + " KB\/s)");
27
26
 
28
- start = new(Date);
27
+ start = new Date();
29
28
  css = tree.toCSS();
30
- end = new(Date);
29
+ end = new Date();
31
30
 
32
- sys.puts("Generation: " + (end - start) + " ms (" +
31
+ console.log("Generation: " + (end - start) + " ms (" +
33
32
  parseInt(1000 / (end - start) *
34
33
  data.length / 1024) + " KB\/s)");
35
34
 
36
35
  total += end - start;
37
36
 
38
- sys.puts("Total: " + total + "ms (" +
39
- parseInt(1000 / total * data.length / 1024) + " KB/s)");
37
+ console.log("Total: " + total + "ms (" +
38
+ Number(1000 / total * data.length / 1024) + " KB/s)");
40
39
 
41
40
  if (err) {
42
41
  less.writeError(err);
@@ -11,7 +11,7 @@ var args = process.argv.slice(1);
11
11
  var options = {
12
12
  depends: false,
13
13
  compress: false,
14
- yuicompress: false,
14
+ cleancss: false,
15
15
  max_line_len: -1,
16
16
  optimization: 1,
17
17
  silent: false,
@@ -20,12 +20,17 @@ var options = {
20
20
  paths: [],
21
21
  color: true,
22
22
  strictImports: false,
23
+ insecure: false,
23
24
  rootpath: '',
24
25
  relativeUrls: false,
25
26
  ieCompat: true,
26
27
  strictMath: false,
27
- strictUnits: false
28
+ strictUnits: false,
29
+ globalVariables: '',
30
+ modifyVariables: '',
31
+ urlArgs: ''
28
32
  };
33
+ var cleancssOptions = {};
29
34
  var continueProcessing = true,
30
35
  currentErrorcode;
31
36
 
@@ -35,7 +40,7 @@ process.on('exit', function() { process.reallyExit(currentErrorcode) });
35
40
 
36
41
  var checkArgFunc = function(arg, option) {
37
42
  if (!option) {
38
- sys.puts(arg + " option requires a parameter");
43
+ console.log(arg + " option requires a parameter");
39
44
  continueProcessing = false;
40
45
  return false;
41
46
  }
@@ -45,13 +50,21 @@ var checkArgFunc = function(arg, option) {
45
50
  var checkBooleanArg = function(arg) {
46
51
  var onOff = /^((on|t|true|y|yes)|(off|f|false|n|no))$/i.exec(arg);
47
52
  if (!onOff) {
48
- sys.puts(" unable to parse "+arg+" as a boolean. use one of on/t/true/y/yes/off/f/false/n/no");
53
+ console.log(" unable to parse "+arg+" as a boolean. use one of on/t/true/y/yes/off/f/false/n/no");
49
54
  continueProcessing = false;
50
55
  return false;
51
56
  }
52
57
  return Boolean(onOff[2]);
53
58
  };
54
59
 
60
+ var parseVariableOption = function(option) {
61
+ var parts = option.split('=', 2);
62
+ return '@' + parts[0] + ': ' + parts[1] + ';\n';
63
+ };
64
+
65
+ var warningMessages = "";
66
+ var sourceMapFileInline = false;
67
+
55
68
  args = args.filter(function (arg) {
56
69
  var match;
57
70
 
@@ -60,13 +73,13 @@ args = args.filter(function (arg) {
60
73
  return false;
61
74
  }
62
75
 
63
- if (match = arg.match(/^--?([a-z][0-9a-z-]*)(?:=([^\s]*))?$/i)) { arg = match[1] }
76
+ if (match = arg.match(/^--?([a-z][0-9a-z-]*)(?:=(.*))?$/i)) { arg = match[1] }
64
77
  else { return arg }
65
78
 
66
79
  switch (arg) {
67
80
  case 'v':
68
81
  case 'version':
69
- sys.puts("lessc " + less.version.join('.') + " (LESS Compiler) [JavaScript]");
82
+ console.log("lessc " + less.version.join('.') + " (LESS Compiler) [JavaScript]");
70
83
  continueProcessing = false;
71
84
  case 'verbose':
72
85
  options.verbose = true;
@@ -90,12 +103,18 @@ args = args.filter(function (arg) {
90
103
  case 'compress':
91
104
  options.compress = true;
92
105
  break;
106
+ case 'insecure':
107
+ options.insecure = true;
108
+ break;
93
109
  case 'M':
94
110
  case 'depends':
95
111
  options.depends = true;
96
112
  break;
97
113
  case 'yui-compress':
98
- options.yuicompress = true;
114
+ warningMessages += "yui-compress option has been removed. ignoring.";
115
+ break;
116
+ case 'clean-css':
117
+ options.cleancss = true;
99
118
  break;
100
119
  case 'max-line-len':
101
120
  if (checkArgFunc(arg, match[2])) {
@@ -111,6 +130,9 @@ args = args.filter(function (arg) {
111
130
  case 'no-ie-compat':
112
131
  options.ieCompat = false;
113
132
  break;
133
+ case 'no-js':
134
+ options.javascriptEnabled = false;
135
+ break;
114
136
  case 'include-path':
115
137
  if (checkArgFunc(arg, match[2])) {
116
138
  options.paths = match[2].split(os.type().match(/Windows/) ? ';' : ':')
@@ -129,6 +151,35 @@ args = args.filter(function (arg) {
129
151
  options.dumpLineNumbers = match[2];
130
152
  }
131
153
  break;
154
+ case 'source-map':
155
+ if (!match[2]) {
156
+ options.sourceMap = true;
157
+ } else {
158
+ options.sourceMap = match[2];
159
+ }
160
+ break;
161
+ case 'source-map-rootpath':
162
+ if (checkArgFunc(arg, match[2])) {
163
+ options.sourceMapRootpath = match[2];
164
+ }
165
+ break;
166
+ case 'source-map-basepath':
167
+ if (checkArgFunc(arg, match[2])) {
168
+ options.sourceMapBasepath = match[2];
169
+ }
170
+ break;
171
+ case 'source-map-map-inline':
172
+ sourceMapFileInline = true;
173
+ options.sourceMap = true;
174
+ break;
175
+ case 'source-map-less-inline':
176
+ options.outputSourceFiles = true;
177
+ break;
178
+ case 'source-map-url':
179
+ if (checkArgFunc(arg, match[2])) {
180
+ options.sourceMapURL = match[2];
181
+ }
182
+ break;
132
183
  case 'rp':
133
184
  case 'rootpath':
134
185
  if (checkArgFunc(arg, match[2])) {
@@ -151,6 +202,57 @@ args = args.filter(function (arg) {
151
202
  options.strictUnits = checkBooleanArg(match[2]);
152
203
  }
153
204
  break;
205
+ case "global-var":
206
+ if (checkArgFunc(arg, match[2])) {
207
+ options.globalVariables += parseVariableOption(match[2]);
208
+ }
209
+ break;
210
+ case "modify-var":
211
+ if (checkArgFunc(arg, match[2])) {
212
+ options.modifyVariables += parseVariableOption(match[2]);
213
+ }
214
+ break;
215
+ case "clean-option":
216
+ var cleanOptionArgs = match[2].split(":");
217
+ switch(cleanOptionArgs[0]) {
218
+ case "--keep-line-breaks":
219
+ case "-b":
220
+ cleancssOptions.keepBreaks = true;
221
+ break;
222
+ case "--s0":
223
+ cleancssOptions.keepSpecialComments = 0;
224
+ break;
225
+ case "--s1":
226
+ cleancssOptions.keepSpecialComments = 1;
227
+ break;
228
+ case "--skip-advanced":
229
+ cleancssOptions.noAdvanced = true;
230
+ break;
231
+ case "--advanced":
232
+ cleancssOptions.noAdvanced = false;
233
+ break;
234
+ case "--selectors-merge-mode":
235
+ cleancssOptions.selectorsMergeMode = cleanOptionArgs[1];
236
+ break;
237
+ default:
238
+ console.log("unrecognised clean-css option '" + cleanOptionArgs[0] + "'");
239
+ console.log("we support only arguments that make sense for less, '--keep-line-breaks', '-b'");
240
+ console.log("'--s0', '--s1', '--advanced', '--skip-advanced', '--selectors-merge-mode'");
241
+ continueProcessing = false;
242
+ currentErrorcode = 1;
243
+ break;
244
+ }
245
+ break;
246
+ case 'url-args':
247
+ if (checkArgFunc(arg, match[2])) {
248
+ options.urlArgs = match[2];
249
+ }
250
+ break;
251
+ default:
252
+ require('../lib/less/lessc_helper').printUsage();
253
+ continueProcessing = false;
254
+ currentErrorcode = 1;
255
+ break;
154
256
  }
155
257
  });
156
258
 
@@ -166,12 +268,32 @@ if (input && input != '-') {
166
268
  var output = args[2];
167
269
  var outputbase = args[2];
168
270
  if (output) {
271
+ options.sourceMapOutputFilename = output;
169
272
  output = path.resolve(process.cwd(), output);
273
+ if (warningMessages) {
274
+ console.log(warningMessages);
275
+ }
276
+ }
277
+
278
+ options.sourceMapBasepath = options.sourceMapBasepath || (input ? path.dirname(input) : process.cwd());
279
+
280
+ if (options.sourceMap === true) {
281
+ if (!output && !sourceMapFileInline) {
282
+ console.log("the sourcemap option only has an optional filename if the css filename is given");
283
+ return;
284
+ }
285
+ options.sourceMapFullFilename = options.sourceMapOutputFilename + ".map";
286
+ options.sourceMap = path.basename(options.sourceMapFullFilename);
287
+ }
288
+
289
+ if (options.cleancss && options.sourceMap) {
290
+ console.log("the sourcemap option is not compatible with sourcemap support at the moment. See Issue #1656");
291
+ return;
170
292
  }
171
293
 
172
294
  if (! input) {
173
- sys.puts("lessc: no input files");
174
- sys.puts("");
295
+ console.log("lessc: no input files");
296
+ console.log("");
175
297
  require('../lib/less/lessc_helper').printUsage();
176
298
  currentErrorcode = 1;
177
299
  return;
@@ -199,13 +321,23 @@ if (options.depends) {
199
321
  sys.print(outputbase + ": ");
200
322
  }
201
323
 
324
+ if (!sourceMapFileInline) {
325
+ var writeSourceMap = function(output) {
326
+ var filename = options.sourceMapFullFilename || options.sourceMap;
327
+ ensureDirectory(filename);
328
+ fs.writeFileSync(filename, output, 'utf8');
329
+ };
330
+ }
331
+
202
332
  var parseLessFile = function (e, data) {
203
333
  if (e) {
204
- sys.puts("lessc: " + e.message);
334
+ console.log("lessc: " + e.message);
205
335
  currentErrorcode = 1;
206
336
  return;
207
337
  }
208
338
 
339
+ data = options.globalVariables + data + options.modifyVariables;
340
+
209
341
  options.paths = [path.dirname(input)].concat(options.paths);
210
342
  options.filename = input;
211
343
 
@@ -227,10 +359,20 @@ var parseLessFile = function (e, data) {
227
359
  verbose: options.verbose,
228
360
  ieCompat: options.ieCompat,
229
361
  compress: options.compress,
230
- yuicompress: options.yuicompress,
362
+ cleancss: options.cleancss,
363
+ cleancssOptions: cleancssOptions,
364
+ sourceMap: Boolean(options.sourceMap),
365
+ sourceMapFilename: options.sourceMap,
366
+ sourceMapURL: options.sourceMapURL,
367
+ sourceMapOutputFilename: options.sourceMapOutputFilename,
368
+ sourceMapBasepath: options.sourceMapBasepath,
369
+ sourceMapRootpath: options.sourceMapRootpath || "",
370
+ outputSourceFiles: options.outputSourceFiles,
371
+ writeSourceMap: writeSourceMap,
231
372
  maxLineLen: options.maxLineLen,
232
373
  strictMath: options.strictMath,
233
- strictUnits: options.strictUnits
374
+ strictUnits: options.strictUnits,
375
+ urlArgs: options.urlArgs
234
376
  });
235
377
  if (output) {
236
378
  ensureDirectory(output);
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "less",
3
+ "version": "1.6.2",
4
+ "main": "./dist/less-1.6.2.js",
5
+ "ignore": [
6
+ "**/.*",
7
+ "benchmark",
8
+ "bin",
9
+ "build",
10
+ "lib",
11
+ "test",
12
+ "*.md",
13
+ "LICENSE",
14
+ "Gruntfile.js",
15
+ "package.json",
16
+ "bower.json"
17
+ ]
18
+ }
@@ -0,0 +1,347 @@
1
+ import groovy.io.FileType
2
+ import org.apache.tools.ant.taskdefs.condition.Os
3
+ import org.gradle.api.tasks.Exec
4
+
5
+ buildscript {
6
+ repositories {
7
+ mavenCentral()
8
+ jcenter()
9
+ }
10
+ dependencies {
11
+ classpath 'com.eriwen:gradle-js-plugin:1.8.0'
12
+ classpath 'com.moowork.gradle:gradle-grunt-plugin:0.2'
13
+ }
14
+ }
15
+
16
+ apply plugin: 'js'
17
+ apply plugin: 'grunt'
18
+
19
+ repositories {
20
+ mavenCentral()
21
+ }
22
+
23
+ configurations {
24
+ rhino
25
+ }
26
+
27
+ dependencies {
28
+ rhino 'org.mozilla:rhino:1.7R4'
29
+ }
30
+
31
+ project.ext {
32
+ packageProps = new groovy.json.JsonSlurper().parseText(new File("package.json").toURL().text)
33
+ failures = 0;
34
+ rhinoTestSrc = "out/rhino-test-${packageProps.version}.js"
35
+ testSrc = 'test/less'
36
+ testOut = 'out/test'
37
+ }
38
+
39
+ task runGruntRhino(type: GruntTask) {
40
+ gruntArgs = "rhino"
41
+ }
42
+
43
+ combineJs {
44
+ dependsOn runGruntRhino
45
+ source = ["dist/less-rhino-${packageProps.version}.js", "test/rhino/test-header.js","dist/lessc-rhino-${packageProps.version}.js"]
46
+ dest = file(rhinoTestSrc)
47
+ }
48
+
49
+ task testRhino(type: AllRhinoTests) {
50
+ // dependsOn 'testRhinoBase'
51
+ dependsOn 'testRhinoBase', 'testRhinoErrors', 'testRhinoLegacy', 'testRhinoStaticUrls', 'testRhinoCompression', 'testRhinoDebugAll', 'testRhinoDebugComments', 'testRhinoDebugMediaquery', 'testRhinoNoJsError', 'testRhinoSourceMap'
52
+ }
53
+
54
+ task testRhinoBase(type: RhinoTest) {
55
+ options = [ '--strict-math=true', '--relative-urls' ]
56
+ }
57
+
58
+ task testRhinoDebugAll(type: DebugRhinoTest) {
59
+ options = [ '--strict-math=true', '--line-numbers=all' ]
60
+ testDir = 'debug' + fs
61
+ suffix = "-all"
62
+ }
63
+
64
+ task testRhinoDebugComments(type: DebugRhinoTest) {
65
+ options = [ '--strict-math=true', '--line-numbers=comments' ]
66
+ testDir = 'debug' + fs
67
+ suffix = "-comments"
68
+ }
69
+
70
+ task testRhinoDebugMediaquery(type: DebugRhinoTest) {
71
+ options = [ '--strict-math=true', '--line-numbers=mediaquery' ]
72
+ testDir = 'debug' + fs
73
+ suffix = "-mediaquery"
74
+ }
75
+
76
+ task testRhinoErrors(type: RhinoTest) {
77
+ options = [ '--strict-math=true', '--strict-units=true' ]
78
+ testDir = 'errors/'
79
+ expectErrors = true
80
+ }
81
+
82
+ task testRhinoChyby(type: RhinoTest) {
83
+ options = [ '--strict-math=true', '--strict-units=true' ]
84
+ testDir = 'chyby/'
85
+ // expectErrors = true
86
+ }
87
+
88
+ task testRhinoNoJsError(type: RhinoTest) {
89
+ options = [ '--strict-math=true', '--strict-units=true', '--no-js' ]
90
+ testDir = 'no-js-errors/'
91
+ expectErrors = true
92
+ }
93
+
94
+ task testRhinoLegacy(type: RhinoTest) {
95
+ testDir = 'legacy/'
96
+ }
97
+
98
+ task testRhinoStaticUrls(type: RhinoTest) {
99
+ options = [ '--strict-math=true', '--rootpath=folder (1)/' ]
100
+ testDir = 'static-urls/'
101
+ }
102
+
103
+ task testRhinoCompression(type: RhinoTest) {
104
+ options = [ '--compress=true' ]
105
+ testDir = 'compression/'
106
+ }
107
+
108
+ task testRhinoSourceMap(type: SourceMapRhinoTest) {
109
+ options = [ '--strict-math=true', '--strict-units=true']
110
+ testDir = 'sourcemaps/'
111
+ }
112
+
113
+ task setupTest {
114
+ dependsOn combineJs
115
+ doLast {
116
+ file(testOut).deleteDir()
117
+ }
118
+ }
119
+
120
+ task clean << {
121
+ file(rhinoTestSrc).delete()
122
+ file(testOut).deleteDir()
123
+ }
124
+
125
+ class SourceMapRhinoTest extends RhinoTest {
126
+
127
+ // helper to get the output map file
128
+ def getOutputMap(lessFile) {
129
+ def outFile = project.file(lessFile.path.replace('test/less', project.testOut).replace('.less', '.css'))
130
+ return project.file(outFile.path + ".map");
131
+ }
132
+
133
+ // callback to add SourceMap options to the options list
134
+ def postProcessOptions(options, lessFile) {
135
+ def outFile = getOutputMap(lessFile)
136
+ project.file(outFile.parent).mkdirs()
137
+ options << "--source-map=${testDir}${lessFile.name.replace('.less','.css')}"
138
+ options << "--source-map-basepath=${lessRootDir}"
139
+ options << "--source-map-rootpath=testweb/"
140
+ options << "--source-map-output-map-file=${outFile}"
141
+
142
+ options
143
+ }
144
+
145
+ // Callback to validate output
146
+ def handleResult(exec, out, lessFile) {
147
+ def actualFile = getOutputMap(lessFile)
148
+ def expectedFile = project.file(projectDir + fs + "test" + fs + testDir + fs + lessFile.name.replace(".less", ".json"))
149
+ assert actualFile.text == expectedFile.text
150
+ }
151
+
152
+ }
153
+
154
+ class DebugRhinoTest extends RhinoTest {
155
+
156
+ def escapeIt(it) {
157
+ return it.replaceAll("\\\\", "\\\\\\\\").replaceAll("/", "\\\\/").replaceAll(":", "\\\\:").replaceAll("\\.", "\\\\.");
158
+ }
159
+
160
+ def globalReplacements(input, directory) {
161
+ def pDirectory = toPlatformFs(directory)
162
+ def p = lessRootDir + fs + pDirectory
163
+ def pathimport = p + toPlatformFs("import/")
164
+ def pathesc = escapeIt(p)
165
+ def pathimportesc = escapeIt(pathimport)
166
+
167
+ def result = input.replace("{path}", p).replace("{pathesc}", pathesc).replace("{pathimport}", pathimport)
168
+ return result.replace("{pathimportesc}", pathimportesc).replace("\r\n", "\n")
169
+ }
170
+ }
171
+
172
+ class RhinoTest extends DefaultTask {
173
+
174
+ RhinoTest() {
175
+ dependsOn 'setupTest'
176
+ }
177
+
178
+ def suffix = ""
179
+ def testDir = ''
180
+ def options = []
181
+ def expectErrors = false
182
+ def fs = File.separator;
183
+ def projectDir = toUpperCaseDriveLetter(System.getProperty("user.dir"));
184
+ def lessRootDir = projectDir + fs + "test" + fs + "less"
185
+
186
+ def toUpperCaseDriveLetter(path) {
187
+ if (path.charAt(1)==':' && path.charAt(2)=='\\') {
188
+ return path.substring(0,1).toUpperCase() + path.substring(1);
189
+ }
190
+ return path;
191
+ }
192
+
193
+ def toPlatformFs(path) {
194
+ return path.replace('\\', fs).replace('/', fs);
195
+ }
196
+
197
+ def expectedCssPath(lessFilePath) {
198
+ lessFilePath.replace('.less', "${suffix}.css").replace("${fs}less${fs}", "${fs}css${fs}");
199
+ }
200
+
201
+ def globalReplacements(input, directory) {
202
+ return input;
203
+ }
204
+
205
+ def stylize(str, style) {
206
+ def styles = [
207
+ reset : [0, 0],
208
+ bold : [1, 22],
209
+ inverse : [7, 27],
210
+ underline : [4, 24],
211
+ yellow : [33, 39],
212
+ green : [32, 39],
213
+ red : [31, 39],
214
+ grey : [90, 39]
215
+ ];
216
+ return '\033[' + styles[style][0] + 'm' + str +
217
+ '\033[' + styles[style][1] + 'm';
218
+ }
219
+
220
+ // Callback for subclasses to make any changes to the options
221
+ def postProcessOptions(options, lessFile) {
222
+ options
223
+ }
224
+
225
+ // Callback to validate output
226
+ def handleResult(exec, out, lessFile) {
227
+ def actual = out.toString().trim()
228
+ def actualResult = project.file(lessFile.path.replace('test/less', project.testOut).replace('.less', '.css'))
229
+ project.file(actualResult.parent).mkdirs()
230
+ actualResult << actual
231
+ def expected
232
+ if (expectErrors) {
233
+ assert exec.exitValue != 0
234
+ expected = project.file(lessFile.path.replace('.less', '.txt')).text.trim().
235
+ replace('{path}', lessFile.parent + '/').
236
+ replace('{pathhref}', '').
237
+ replace('{404status}', '')
238
+ } else {
239
+ assert exec.exitValue == 0
240
+ def expectedFile = expectedCssPath(lessFile.path)
241
+ expected = project.file(expectedFile).text.trim()
242
+ expected = globalReplacements(expected, testDir)
243
+ }
244
+ actual=actual.trim()
245
+ actual = actual.replace('\r\n', '\n')
246
+ expected = expected.replace('\r\n', '\n')
247
+ actual = actual.replace("/","\\")
248
+ expected = expected.replace("/","\\")
249
+ // println "* actual *"
250
+ // println actual
251
+ // new File("actual.txt").write(actual)
252
+ // println "* expected *"
253
+ // println expected
254
+ // new File("expected.txt").write(expected)
255
+ assert actual == expected
256
+ actualResult.delete()
257
+
258
+ }
259
+
260
+ @TaskAction
261
+ def runTest() {
262
+ int testSuccesses = 0, testFailures = 0, testErrors = 0
263
+ project.file('test/less/' + testDir).eachFileMatch(FileType.FILES, ~/.*\.less/) { lessFile ->
264
+ println "lessfile: $lessFile"
265
+ if (!project.hasProperty('test') || lessFile.name.startsWith(project.test)) {
266
+ def out = new java.io.ByteArrayOutputStream()
267
+ def processedOptions = postProcessOptions([project.rhinoTestSrc, lessFile] + options, lessFile)
268
+ def execOptions = {
269
+ main = 'org.mozilla.javascript.tools.shell.Main'
270
+ // main = 'org.mozilla.javascript.tools.debugger.Main'
271
+ classpath = project.configurations.rhino
272
+ args = processedOptions
273
+ standardOutput = out
274
+ ignoreExitValue = true
275
+ }
276
+ println "rhinoTestSrc: ${project.rhinoTestSrc}"
277
+ try {
278
+ def exec = project.javaexec(execOptions)
279
+ handleResult(exec, out, lessFile)
280
+ testSuccesses++
281
+ println stylize(' ok', 'green')
282
+ }
283
+ catch (ex) {
284
+ println ex
285
+ println()
286
+ testErrors++;
287
+ }
288
+ catch (AssertionError ae) {
289
+ println stylize(' failed', 'red')
290
+ println ae
291
+ testFailures++
292
+ }
293
+ } else {
294
+ println stylize(' skipped', 'yellow')
295
+ }
296
+ }
297
+ println stylize(testSuccesses + ' ok', 'green')
298
+ println stylize(testFailures + ' assertion failed', testFailures == 0 ? 'green' : 'red')
299
+ println stylize(testErrors + ' errors', testErrors == 0 ? 'green' : 'red')
300
+ if (testFailures != 0 || testErrors != 0) {
301
+ project.failures++;
302
+ }
303
+ }
304
+ }
305
+
306
+ class AllRhinoTests extends DefaultTask {
307
+
308
+ AllRhinoTests() {
309
+ }
310
+
311
+ @TaskAction
312
+ def runTest() {
313
+ println stylize(project.failures + ' test suites failed', project.failures == 0 ? 'green' : 'red')
314
+ }
315
+
316
+ def stylize(str, style) {
317
+ def styles = [
318
+ reset : [0, 0],
319
+ bold : [1, 22],
320
+ inverse : [7, 27],
321
+ underline : [4, 24],
322
+ yellow : [33, 39],
323
+ green : [32, 39],
324
+ red : [31, 39],
325
+ grey : [90, 39]
326
+ ];
327
+ return '\033[' + styles[style][0] + 'm' + str +
328
+ '\033[' + styles[style][1] + 'm';
329
+ }
330
+ }
331
+
332
+ class GruntTask extends Exec {
333
+ private String gruntExecutable = Os.isFamily(Os.FAMILY_WINDOWS) ? "grunt.cmd" : "grunt"
334
+ private String switches = "--no-color"
335
+
336
+ String gruntArgs = ""
337
+
338
+ public GruntTask() {
339
+ super()
340
+ this.setExecutable(gruntExecutable)
341
+ }
342
+
343
+ public void setGruntArgs(String gruntArgs) {
344
+ this.args = "$switches $gruntArgs".trim().split(" ") as List
345
+ }
346
+ }
347
+