less 1.2.2 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/.npmignore +1 -0
  2. package/CHANGELOG.md +118 -0
  3. package/CONTRIBUTING.md +50 -0
  4. package/Makefile +14 -2
  5. package/benchmark/benchmark.less +11 -11
  6. package/benchmark/less-benchmark.js +1 -1
  7. package/bin/lessc +77 -21
  8. package/build/amd.js +6 -0
  9. package/build/ecma-5.js +120 -0
  10. package/build/header.js +7 -0
  11. package/build/require-rhino.js +7 -0
  12. package/build/require.js +7 -0
  13. package/lib/less/browser.js +192 -53
  14. package/lib/less/colors.js +1 -0
  15. package/lib/less/functions.js +159 -10
  16. package/lib/less/index.js +125 -56
  17. package/lib/less/lessc_helper.js +62 -0
  18. package/lib/less/parser.js +391 -154
  19. package/lib/less/rhino.js +84 -23
  20. package/lib/less/tree/anonymous.js +15 -1
  21. package/lib/less/tree/assignment.js +3 -1
  22. package/lib/less/tree/call.js +12 -6
  23. package/lib/less/tree/color.js +10 -0
  24. package/lib/less/tree/dimension.js +3 -1
  25. package/lib/less/tree/directive.js +10 -10
  26. package/lib/less/tree/element.js +8 -7
  27. package/lib/less/tree/import.js +17 -14
  28. package/lib/less/tree/media.js +121 -0
  29. package/lib/less/tree/mixin.js +133 -45
  30. package/lib/less/tree/operation.js +5 -0
  31. package/lib/less/tree/quoted.js +15 -1
  32. package/lib/less/tree/ratio.js +13 -0
  33. package/lib/less/tree/rule.js +7 -0
  34. package/lib/less/tree/ruleset.js +236 -37
  35. package/lib/less/tree/selector.js +21 -11
  36. package/lib/less/tree/unicode-descriptor.js +13 -0
  37. package/lib/less/tree/url.js +16 -14
  38. package/lib/less/tree/variable.js +13 -1
  39. package/lib/less/tree.js +28 -0
  40. package/package.json +13 -3
  41. package/test/browser/common.js +74 -0
  42. package/test/browser/css/relative-urls/urls.css +36 -0
  43. package/test/browser/css/rootpath/urls.css +36 -0
  44. package/test/browser/css/rootpath-relative/urls.css +36 -0
  45. package/test/browser/css/urls.css +36 -0
  46. package/test/browser/jasmine-html.js +681 -0
  47. package/test/browser/jasmine.css +82 -0
  48. package/test/browser/jasmine.js +2600 -0
  49. package/test/browser/less/imports/urls.less +4 -0
  50. package/test/browser/less/imports/urls2.less +4 -0
  51. package/test/browser/less/relative-urls/urls.less +33 -0
  52. package/test/browser/less/rootpath/urls.less +33 -0
  53. package/test/browser/less/rootpath-relative/urls.less +33 -0
  54. package/test/browser/less/urls.less +33 -0
  55. package/test/browser/phantom-runner.js +139 -0
  56. package/test/browser/runner-browser.js +3 -0
  57. package/test/browser/runner-main.js +15 -0
  58. package/test/browser/runner-relative-urls.js +4 -0
  59. package/test/browser/runner-rootpath-relative.js +5 -0
  60. package/test/browser/runner-rootpath.js +4 -0
  61. package/test/browser/template.htm +10 -0
  62. package/test/browser-test-prepare.js +29 -0
  63. package/test/css/charsets.css +1 -0
  64. package/test/css/colors.css +22 -0
  65. package/test/css/comments.css +7 -0
  66. package/test/css/css-3.css +57 -2
  67. package/test/css/css-escapes.css +4 -0
  68. package/test/css/css.css +11 -11
  69. package/test/css/debug/linenumbers-all.css +43 -0
  70. package/test/css/debug/linenumbers-comments.css +35 -0
  71. package/test/css/debug/linenumbers-mediaquery.css +35 -0
  72. package/test/css/functions.css +59 -2
  73. package/test/css/ie-filters.css +7 -3
  74. package/test/css/import-once.css +3 -0
  75. package/test/css/import.css +7 -9
  76. package/test/css/javascript.css +3 -2
  77. package/test/css/media.css +168 -0
  78. package/test/css/mixins-args.css +35 -4
  79. package/test/css/mixins-guards.css +13 -0
  80. package/test/css/mixins-important.css +21 -0
  81. package/test/css/mixins-named-args.css +27 -0
  82. package/test/css/mixins-pattern.css +4 -6
  83. package/test/css/mixins.css +50 -0
  84. package/test/css/scope.css +20 -0
  85. package/test/css/selectors.css +76 -0
  86. package/test/css/static-urls/urls.css +42 -0
  87. package/test/css/strings.css +2 -2
  88. package/test/css/urls.css +42 -0
  89. package/test/css/variables.css +0 -1
  90. package/test/css/whitespace.css +4 -0
  91. package/test/less/charsets.less +3 -0
  92. package/test/less/colors.less +27 -0
  93. package/test/less/comments.less +12 -0
  94. package/test/less/css-3.less +54 -6
  95. package/test/less/css-escapes.less +6 -1
  96. package/test/less/css.less +14 -12
  97. package/test/less/debug/import/test.less +25 -0
  98. package/test/less/debug/linenumbers.less +23 -0
  99. package/test/less/errors/bad-variable-declaration1.less +1 -0
  100. package/test/less/errors/bad-variable-declaration1.txt +2 -0
  101. package/test/less/errors/comment-in-selector.less +1 -0
  102. package/test/less/errors/comment-in-selector.txt +2 -0
  103. package/test/less/errors/import-missing.less +1 -0
  104. package/test/less/errors/import-missing.txt +3 -0
  105. package/test/less/errors/import-no-semi.less +1 -0
  106. package/test/less/errors/import-no-semi.txt +2 -0
  107. package/test/less/errors/import-subfolder1.less +1 -0
  108. package/test/less/errors/import-subfolder1.txt +3 -0
  109. package/test/less/errors/import-subfolder2.less +1 -0
  110. package/test/less/errors/import-subfolder2.txt +2 -0
  111. package/test/less/errors/imports/import-subfolder1.less +1 -0
  112. package/test/less/errors/imports/import-subfolder2.less +1 -0
  113. package/test/less/errors/imports/import-test.less +4 -0
  114. package/test/less/errors/imports/subfolder/mixin-not-defined.less +1 -0
  115. package/test/less/errors/imports/subfolder/parse-error-curly-bracket.less +1 -0
  116. package/test/less/errors/javascript-error.less +3 -0
  117. package/test/less/errors/javascript-error.txt +4 -0
  118. package/test/less/errors/mixed-mixin-definition-args-1.less +6 -0
  119. package/test/less/errors/mixed-mixin-definition-args-1.txt +4 -0
  120. package/test/less/errors/mixed-mixin-definition-args-2.less +6 -0
  121. package/test/less/errors/mixed-mixin-definition-args-2.txt +4 -0
  122. package/test/less/errors/mixin-not-defined.less +11 -0
  123. package/test/less/errors/mixin-not-defined.txt +3 -0
  124. package/test/less/errors/mixin-not-matched.less +6 -0
  125. package/test/less/errors/mixin-not-matched.txt +3 -0
  126. package/test/less/errors/mixin-not-matched2.less +6 -0
  127. package/test/less/errors/mixin-not-matched2.txt +3 -0
  128. package/test/less/errors/parse-error-curly-bracket.less +1 -0
  129. package/test/less/errors/parse-error-curly-bracket.txt +2 -0
  130. package/test/less/errors/parse-error-missing-bracket.less +2 -0
  131. package/test/less/errors/parse-error-missing-bracket.txt +2 -0
  132. package/test/less/errors/parse-error-with-import.less +13 -0
  133. package/test/less/errors/parse-error-with-import.txt +4 -0
  134. package/test/less/errors/property-ie5-hack.less +3 -0
  135. package/test/less/errors/property-ie5-hack.txt +4 -0
  136. package/test/less/errors/recursive-variable.less +1 -0
  137. package/test/less/errors/recursive-variable.txt +2 -0
  138. package/test/less/functions.less +64 -2
  139. package/test/less/ie-filters.less +7 -0
  140. package/test/less/import/deeper/import-once-test-a.less +1 -0
  141. package/test/less/import/import-and-relative-paths-test.less +6 -0
  142. package/test/less/import/import-charset-test.less +1 -0
  143. package/test/less/import/import-once-test-c.less +6 -0
  144. package/test/less/import/import-test-a.less +1 -0
  145. package/test/less/import/import-test-c.less +0 -1
  146. package/test/less/import/imports/font.less +8 -0
  147. package/test/less/import/imports/logo.less +5 -0
  148. package/test/less/import/urls.less +1 -0
  149. package/test/less/import-once.less +4 -0
  150. package/test/less/import.less +2 -1
  151. package/test/less/javascript.less +4 -2
  152. package/test/less/media.less +169 -1
  153. package/test/less/mixins-args.less +54 -11
  154. package/test/less/mixins-guards.less +30 -0
  155. package/test/less/mixins-important.less +4 -0
  156. package/test/less/mixins-named-args.less +36 -0
  157. package/test/less/mixins-pattern.less +3 -0
  158. package/test/less/mixins.less +47 -0
  159. package/test/less/scope.less +48 -1
  160. package/test/less/selectors.less +88 -0
  161. package/test/less/static-urls/urls.less +33 -0
  162. package/test/less/strings.less +1 -1
  163. package/test/less/urls.less +33 -0
  164. package/test/less/variables.less +0 -1
  165. package/test/less/whitespace.less +7 -0
  166. package/test/less-test.js +145 -36
  167. package/bench.css +0 -5943
  168. package/benchmark/b1.less +0 -3980
  169. package/dist/less-1.1.0.js +0 -2695
  170. package/dist/less-1.1.0.min.js +0 -16
  171. package/dist/less-1.1.1.js +0 -2710
  172. package/dist/less-1.1.1.min.js +0 -16
  173. package/dist/less-1.1.2.js +0 -2712
  174. package/dist/less-1.1.2.min.js +0 -16
  175. package/dist/less-1.1.3.js +0 -2721
  176. package/dist/less-1.1.3.min.js +0 -16
  177. package/dist/less-1.1.4.js +0 -2769
  178. package/dist/less-1.1.4.min.js +0 -16
  179. package/dist/less-1.1.5.js +0 -2805
  180. package/dist/less-1.1.5.min.js +0 -9
  181. package/dist/less-1.1.6.js +0 -3004
  182. package/dist/less-1.1.6.min.js +0 -9
  183. package/dist/less-1.2.0.js +0 -3293
  184. package/dist/less-1.2.0.min.js +0 -9
  185. package/dist/less-1.2.1.js +0 -3318
  186. package/dist/less-1.2.1.min.js +0 -9
  187. package/dist/less-1.2.2.js +0 -3337
  188. package/dist/less-1.2.2.min.js +0 -9
  189. package/dist/less-rhino-1.1.3.js +0 -2460
  190. package/dist/less-rhino-1.1.5.js +0 -2481
  191. package/foo.less +0 -2
  192. package/lib/less/cssmin.js +0 -355
  193. package/test/html/index.html +0 -10
  194. package/test/html/less.js +0 -3333
  195. package/test/html/lib.less +0 -2
  196. package/test/html/styles.less +0 -8
  197. package/x.less +0 -4
package/.npmignore ADDED
@@ -0,0 +1 @@
1
+ dist/*
package/CHANGELOG.md ADDED
@@ -0,0 +1,118 @@
1
+ # 1.3.3
2
+
3
+ 2012-12-30
4
+
5
+ - Fix critical bug with mixin call if using multiple brackets
6
+ - when using the filter contrast function, the function is passed through if the first argument is not a color
7
+
8
+ # 1.3.2
9
+
10
+ 2012-12-28
11
+
12
+ - browser and server url re-writing is now aligned to not re-write (previous lessc behaviour)
13
+ - url-rewriting can be made to re-write to be relative to the entry file using the relative-urls option (less.relativeUrls option)
14
+ - rootpath option can be used to add a base path to every url
15
+ - Support mixin argument seperator of ';' so you can pass comma seperated values. e.g. `.mixin(23px, 12px;);`
16
+ - Fix lots of problems with named arguments in corner cases, not behaving as expected
17
+ - hsv, hsva, unit functions
18
+ - fixed lots more bad error messages
19
+ - fix `@import-once` to use the full path, not the relative one for determining if an import has been imported already
20
+ - support `:not(:nth-child(3))`
21
+ - mixin guards take units into account
22
+ - support unicode descriptors (`U+00A1-00A9`)
23
+ - support calling mixins with a stack when using `&` (broken in 1.3.1)
24
+ - support `@namespace` and namespace combinators
25
+ - when using % with colour functions, take into account a colour is out of 256
26
+ - when doing maths with a % do not divide by 100 and keep the unit
27
+ - allow url to contain % (e.g. %20 for a space)
28
+ - if a mixin guard stops execution a default mixin is not required
29
+ - units are output in strings (use the unit function if you need to get the value without unit)
30
+ - do not infinite recurse when mixins call mixins of the same name
31
+ - fix issue on important on mixin calls
32
+ - fix issue with multiple comments being confused
33
+ - tolerate multiple semi-colons on rules
34
+ - ignore subsequant `@charset`
35
+ - syncImport option for node.js to read files syncronously
36
+ - write the output directory if it is missing
37
+ - change dependency on cssmin to ycssmin
38
+ - lessc can load files over http
39
+ - allow calling less.watch() in non dev mode
40
+ - don't cache in dev mode
41
+ - less files cope with query parameters better
42
+ - sass debug statements are now chrome compatible
43
+ - modifyVars function added to re-render with different root variables
44
+
45
+ # 1.3.1
46
+
47
+ 2012-10-18
48
+
49
+ - Support for comment and @media debugging statements
50
+ - bug fix for async access in chrome extensions
51
+ - new functions tint, shade, multiply, screen, overlay, hardlight, difference, exclusion, average, negation, softlight, red, green, blue, contrast
52
+ - allow escaped characters in attributes
53
+ - in selectors support @{a} directly, e.g. .a.@{a} { color: black; }
54
+ - add fraction parameter to round function
55
+ - much better support for & selector
56
+ - preserve order of link statements client side
57
+ - lessc has better help
58
+ - rhino version fixed
59
+ - fix bugs in clientside error handling
60
+ - support dpi, vmin, vm, dppx, dpcm units
61
+ - Fix ratios in media statements
62
+ - in mixin guards allow comparing colors and strings
63
+ - support for -*-keyframes (for -khtml but now supports any)
64
+ - in mix function, default weight to 50%
65
+ - support @import-once
66
+ - remove duplicate rules in output
67
+ - implement named parameters when calling mixins
68
+ - many numerous bug fixes
69
+
70
+ # 1.3.0
71
+
72
+ 2012-03-10
73
+
74
+ - @media bubbling
75
+ - Support arbitrary entities as selectors
76
+ - [Variadic argument support](https://gist.github.com/1933613)
77
+ - Behaviour of zero-arity mixins has [changed](https://gist.github.com/1933613)
78
+ - Allow `@import` directives in any selector
79
+ - Media-query features can now be a variable
80
+ - Automatic merging of media-query conditions
81
+ - Fix global variable leaks
82
+ - Fix error message on wrong-arity call
83
+ - Fix an `@arguments` behaviour bug
84
+ - Fix `::` selector output
85
+ - Fix a bug when using @media with mixins
86
+
87
+
88
+ # 1.2.1
89
+
90
+ 2012-01-15
91
+
92
+ - Fix imports in browser
93
+ - Improve error reporting in browser
94
+ - Fix Runtime error reports from imported files
95
+ - Fix `File not found` import error reporting
96
+
97
+
98
+ # 1.2.0
99
+
100
+ 2012-01-07
101
+
102
+ - Mixin guards
103
+ - New function `percentage`
104
+ - New `color` function to parse hex color strings
105
+ - New type-checking stylesheet functions
106
+ - Fix Rhino support
107
+ - Fix bug in string arguments to mixin call
108
+ - Fix error reporting when index is 0
109
+ - Fix browser support in WebKit and IE
110
+ - Fix string interpolation bug when var is empty
111
+ - Support `!important` after mixin calls
112
+ - Support vanilla @keyframes directive
113
+ - Support variables in certain css selectors, like `nth-child`
114
+ - Support @media and @import features properly
115
+ - Improve @import support with media features
116
+ - Improve error reports from imported files
117
+ - Improve function call error reporting
118
+ - Improve error-reporting
@@ -0,0 +1,50 @@
1
+ ## Bug Reports
2
+
3
+ - Please create a short test case
4
+ - Test with the latest version
5
+ - indicate how you use less - browser/lessc/external tool
6
+
7
+ ## Feature Requests
8
+
9
+ - Please search feature requests to see if something similar exists already
10
+ - include a use-case - we do not add language features without a reason
11
+ - consider whether your language feature would be better as a function
12
+
13
+ ## Pull Requests
14
+
15
+ Thankyou! Please take the time to read these guidelines
16
+
17
+ - Consider adding a feature request first to see if people are pro or con
18
+ - do not change the dist/ folder - we do this when releasing
19
+ - tests - please add tests for your work. use `make test` to see if they pass
20
+ - spaces not tabs
21
+ - end lines in semi-colons - loosely aim towards jslint standards
22
+
23
+ ## Developing
24
+
25
+ 1. install cygwin - http://cygwin.com/install.html
26
+ - default options +
27
+ - Devel -> Make
28
+ -> Git
29
+ 2. install node.js - http://nodejs.org/
30
+ 3. install phantomJS - http://phantomjs.org/download.html
31
+ - copy to a directory of your choice
32
+ - (windows) modify the path directory to include whereever you have copied it
33
+ 4. clone the repository and download to local computer
34
+ 5. run `npm install -g diff` to get diffs in your tests
35
+
36
+ `lessc or node bin/lessc`
37
+
38
+ to run the less compiler
39
+
40
+ `make test`
41
+
42
+ runs the node tests
43
+
44
+ `make browser-test`
45
+
46
+ runs the headless browser tests
47
+
48
+ `make browser-test-server`
49
+
50
+ sets up the server for the headless tests.. then go to http://localhost:8081/browser/test-runner-main.htm or one of the other test runner pages created in /test/browser/
package/Makefile CHANGED
@@ -21,22 +21,33 @@ DIST = dist/less-${VERSION}.js
21
21
  RHINO = dist/less-rhino-${VERSION}.js
22
22
  DIST_MIN = dist/less-${VERSION}.min.js
23
23
 
24
+ browser-prepare: DIST := test/browser/less.js
25
+
24
26
  less:
25
27
  @@mkdir -p dist
26
28
  @@touch ${DIST}
27
29
  @@cat ${HEADER} | sed s/@VERSION/${VERSION}/ > ${DIST}
28
30
  @@echo "(function (window, undefined) {" >> ${DIST}
29
31
  @@cat build/require.js\
30
- build/amd.js\
31
32
  build/ecma-5.js\
32
33
  ${SRC}/parser.js\
33
34
  ${SRC}/functions.js\
34
35
  ${SRC}/colors.js\
35
36
  ${SRC}/tree/*.js\
36
37
  ${SRC}/tree.js\
37
- ${SRC}/browser.js >> ${DIST}
38
+ ${SRC}/browser.js\
39
+ build/amd.js >> ${DIST}
38
40
  @@echo "})(window);" >> ${DIST}
39
41
  @@echo ${DIST} built.
42
+
43
+ browser-prepare: less
44
+ node test/browser-test-prepare.js
45
+
46
+ browser-test: browser-prepare
47
+ phantomjs test/browser/phantom-runner.js
48
+
49
+ browser-test-server: browser-prepare
50
+ phantomjs test/browser/phantom-runner.js --no-tests
40
51
 
41
52
  rhino:
42
53
  @@mkdir -p dist
@@ -45,6 +56,7 @@ rhino:
45
56
  build/ecma-5.js\
46
57
  ${SRC}/parser.js\
47
58
  ${SRC}/functions.js\
59
+ ${SRC}/colors.js\
48
60
  ${SRC}/tree/*.js\
49
61
  ${SRC}/tree.js\
50
62
  ${SRC}/rhino.js > ${RHINO}
@@ -11,27 +11,27 @@
11
11
  @colour_positive: #ff0000;
12
12
  @colour_negative: #ff0000;
13
13
 
14
- .box_shadow () {
14
+ .box_shadow (...) {
15
15
  }
16
- .text_shadow () {
16
+ .text_shadow (...) {
17
17
  }
18
- .border_radius () {
18
+ .border_radius (...) {
19
19
  }
20
- .border_radius_top_left () {
20
+ .border_radius_top_left (...) {
21
21
  }
22
- .border_radius_top_right () {
22
+ .border_radius_top_right (...) {
23
23
  }
24
- .border_radius_bottom_right () {
24
+ .border_radius_bottom_right (...) {
25
25
  }
26
- .border_radius_bottom_left () {
26
+ .border_radius_bottom_left (...) {
27
27
  }
28
- .border_radius_top () {
28
+ .border_radius_top (...) {
29
29
  }
30
- .border_radius_right () {
30
+ .border_radius_right (...) {
31
31
  }
32
- .border_radius_bottom () {
32
+ .border_radius_bottom (...) {
33
33
  }
34
- .border_radius_left () {
34
+ .border_radius_left (...) {
35
35
  }
36
36
  div.browse {
37
37
  margin: 0 0 20px;
@@ -10,7 +10,7 @@ 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("Bechmarking...\n", path.basename(file) + " (" +
13
+ sys.puts("Benchmarking...\n", path.basename(file) + " (" +
14
14
  parseInt(data.length / 1024) + " KB)", "");
15
15
 
16
16
  start = new(Date);
package/bin/lessc CHANGED
@@ -13,8 +13,17 @@ var options = {
13
13
  optimization: 1,
14
14
  silent: false,
15
15
  paths: [],
16
- color: true
16
+ color: true,
17
+ strictImports: false,
18
+ rootpath: '',
19
+ relativeUrls: false
17
20
  };
21
+ var continueProcessing = true,
22
+ currentErrorcode;
23
+
24
+ // calling process.exit does not flush stdout always
25
+ // so use this to set the exit code
26
+ process.on('exit', function() { process.reallyExit(currentErrorcode) });
18
27
 
19
28
  args = args.filter(function (arg) {
20
29
  var match;
@@ -31,7 +40,7 @@ args = args.filter(function (arg) {
31
40
  case 'v':
32
41
  case 'version':
33
42
  sys.puts("lessc " + less.version.join('.') + " (LESS Compiler) [JavaScript]");
34
- process.exit(0);
43
+ continueProcessing = false;
35
44
  case 'verbose':
36
45
  options.verbose = true;
37
46
  break;
@@ -39,10 +48,13 @@ args = args.filter(function (arg) {
39
48
  case 'silent':
40
49
  options.silent = true;
41
50
  break;
51
+ case 'strict-imports':
52
+ options.strictImports = true;
53
+ break;
42
54
  case 'h':
43
55
  case 'help':
44
- sys.puts("usage: lessc source [destination]");
45
- process.exit(0);
56
+ require('../lib/less/lessc_helper').printUsage();
57
+ continueProcessing = false;
46
58
  case 'x':
47
59
  case 'compress':
48
60
  options.compress = true;
@@ -54,19 +66,44 @@ args = args.filter(function (arg) {
54
66
  options.color = false;
55
67
  break;
56
68
  case 'include-path':
57
- options.paths = match[2].split(os.type().match(/Windows/) ? ';' : ':')
58
- .map(function(p) {
59
- if (p) {
60
- return path.resolve(process.cwd(), p);
61
- }
62
- });
69
+ if (!match[2]) {
70
+ sys.puts("include-path option requires a parameter");
71
+ continueProcessing = false;
72
+ } else {
73
+ options.paths = match[2].split(os.type().match(/Windows/) ? ';' : ':')
74
+ .map(function(p) {
75
+ if (p) {
76
+ return path.resolve(process.cwd(), p);
77
+ }
78
+ });
79
+ }
63
80
  break;
64
81
  case 'O0': options.optimization = 0; break;
65
82
  case 'O1': options.optimization = 1; break;
66
83
  case 'O2': options.optimization = 2; break;
84
+ case 'line-numbers':
85
+ options.dumpLineNumbers = match[2];
86
+ break;
87
+ case 'rp':
88
+ case 'rootpath':
89
+ if (!match[2]) {
90
+ sys.puts("rootpath option requires a parameter");
91
+ continueProcessing = false;
92
+ } else {
93
+ options.rootpath = path.normalize(match[2] + '/').replace('\\', '/');
94
+ }
95
+ break;
96
+ case "ru":
97
+ case "relative-urls":
98
+ options.relativeUrls = true;
99
+ break;
67
100
  }
68
101
  });
69
102
 
103
+ if (!continueProcessing) {
104
+ return;
105
+ }
106
+
70
107
  var input = args[1];
71
108
  if (input && input != '-') {
72
109
  input = path.resolve(process.cwd(), input);
@@ -76,49 +113,68 @@ if (output) {
76
113
  output = path.resolve(process.cwd(), output);
77
114
  }
78
115
 
79
- var css, fd, tree;
80
-
81
116
  if (! input) {
82
117
  sys.puts("lessc: no input files");
83
- process.exit(1);
118
+ sys.puts("");
119
+ require('../lib/less/lessc_helper').printUsage();
120
+ currentErrorcode = 1;
121
+ return;
84
122
  }
85
123
 
124
+ var ensureDirectory = function (filepath) {
125
+ var dir = path.dirname(filepath),
126
+ existsSync = fs.existsSync || path.existsSync;
127
+ if (!existsSync(dir)) {
128
+ fs.mkdirSync(dir);
129
+ }
130
+ };
131
+
86
132
  var parseLessFile = function (e, data) {
87
133
  if (e) {
88
134
  sys.puts("lessc: " + e.message);
89
- process.exit(1);
135
+ currentErrorcode = 1;
136
+ return;
90
137
  }
91
138
 
92
139
  new(less.Parser)({
93
140
  paths: [path.dirname(input)].concat(options.paths),
94
141
  optimization: options.optimization,
95
- filename: input
142
+ filename: input,
143
+ rootpath: options.rootpath,
144
+ relativeUrls: options.relativeUrls,
145
+ strictImports: options.strictImports,
146
+ dumpLineNumbers: options.dumpLineNumbers
96
147
  }).parse(data, function (err, tree) {
97
148
  if (err) {
98
149
  less.writeError(err, options);
99
- process.exit(1);
150
+ currentErrorcode = 1;
151
+ return;
100
152
  } else {
101
153
  try {
102
- css = tree.toCSS({
154
+ var css = tree.toCSS({
103
155
  compress: options.compress,
104
156
  yuicompress: options.yuicompress
105
157
  });
106
158
  if (output) {
107
- fd = fs.openSync(output, "w");
108
- fs.writeSync(fd, css, 0, "utf8");
159
+ ensureDirectory(output);
160
+ fs.writeFileSync(output, css, 'utf8');
161
+ if (options.verbose) {
162
+ console.log('lessc: wrote ' + output);
163
+ }
109
164
  } else {
110
165
  sys.print(css);
111
166
  }
112
167
  } catch (e) {
113
168
  less.writeError(e, options);
114
- process.exit(2);
169
+ currentErrorcode = 2;
170
+ return;
115
171
  }
116
172
  }
117
173
  });
118
174
  };
119
175
 
120
176
  if (input != '-') {
121
- fs.readFile(input, 'utf-8', parseLessFile);
177
+ fs.readFile(input, 'utf8', parseLessFile);
122
178
  } else {
123
179
  process.stdin.resume();
124
180
  process.stdin.setEncoding('utf8');
package/build/amd.js ADDED
@@ -0,0 +1,6 @@
1
+ // amd.js
2
+ //
3
+ // Define Less as an AMD module.
4
+ if (typeof define === "function" && define.amd) {
5
+ define("less", [], function () { return less; } );
6
+ }
@@ -0,0 +1,120 @@
1
+
2
+ // ecma-5.js
3
+ //
4
+ // -- kriskowal Kris Kowal Copyright (C) 2009-2010 MIT License
5
+ // -- tlrobinson Tom Robinson
6
+ // dantman Daniel Friesen
7
+
8
+ //
9
+ // Array
10
+ //
11
+ if (!Array.isArray) {
12
+ Array.isArray = function(obj) {
13
+ return Object.prototype.toString.call(obj) === "[object Array]" ||
14
+ (obj instanceof Array);
15
+ };
16
+ }
17
+ if (!Array.prototype.forEach) {
18
+ Array.prototype.forEach = function(block, thisObject) {
19
+ var len = this.length >>> 0;
20
+ for (var i = 0; i < len; i++) {
21
+ if (i in this) {
22
+ block.call(thisObject, this[i], i, this);
23
+ }
24
+ }
25
+ };
26
+ }
27
+ if (!Array.prototype.map) {
28
+ Array.prototype.map = function(fun /*, thisp*/) {
29
+ var len = this.length >>> 0;
30
+ var res = new Array(len);
31
+ var thisp = arguments[1];
32
+
33
+ for (var i = 0; i < len; i++) {
34
+ if (i in this) {
35
+ res[i] = fun.call(thisp, this[i], i, this);
36
+ }
37
+ }
38
+ return res;
39
+ };
40
+ }
41
+ if (!Array.prototype.filter) {
42
+ Array.prototype.filter = function (block /*, thisp */) {
43
+ var values = [];
44
+ var thisp = arguments[1];
45
+ for (var i = 0; i < this.length; i++) {
46
+ if (block.call(thisp, this[i])) {
47
+ values.push(this[i]);
48
+ }
49
+ }
50
+ return values;
51
+ };
52
+ }
53
+ if (!Array.prototype.reduce) {
54
+ Array.prototype.reduce = function(fun /*, initial*/) {
55
+ var len = this.length >>> 0;
56
+ var i = 0;
57
+
58
+ // no value to return if no initial value and an empty array
59
+ if (len === 0 && arguments.length === 1) throw new TypeError();
60
+
61
+ if (arguments.length >= 2) {
62
+ var rv = arguments[1];
63
+ } else {
64
+ do {
65
+ if (i in this) {
66
+ rv = this[i++];
67
+ break;
68
+ }
69
+ // if array contains no values, no initial value to return
70
+ if (++i >= len) throw new TypeError();
71
+ } while (true);
72
+ }
73
+ for (; i < len; i++) {
74
+ if (i in this) {
75
+ rv = fun.call(null, rv, this[i], i, this);
76
+ }
77
+ }
78
+ return rv;
79
+ };
80
+ }
81
+ if (!Array.prototype.indexOf) {
82
+ Array.prototype.indexOf = function (value /*, fromIndex */ ) {
83
+ var length = this.length;
84
+ var i = arguments[1] || 0;
85
+
86
+ if (!length) return -1;
87
+ if (i >= length) return -1;
88
+ if (i < 0) i += length;
89
+
90
+ for (; i < length; i++) {
91
+ if (!Object.prototype.hasOwnProperty.call(this, i)) { continue }
92
+ if (value === this[i]) return i;
93
+ }
94
+ return -1;
95
+ };
96
+ }
97
+
98
+ //
99
+ // Object
100
+ //
101
+ if (!Object.keys) {
102
+ Object.keys = function (object) {
103
+ var keys = [];
104
+ for (var name in object) {
105
+ if (Object.prototype.hasOwnProperty.call(object, name)) {
106
+ keys.push(name);
107
+ }
108
+ }
109
+ return keys;
110
+ };
111
+ }
112
+
113
+ //
114
+ // String
115
+ //
116
+ if (!String.prototype.trim) {
117
+ String.prototype.trim = function () {
118
+ return String(this).replace(/^\s\s*/, '').replace(/\s\s*$/, '');
119
+ };
120
+ }
@@ -0,0 +1,7 @@
1
+ //
2
+ // LESS - Leaner CSS v@VERSION
3
+ // http://lesscss.org
4
+ //
5
+ // Copyright (c) 2009-2011, Alexis Sellier
6
+ // Licensed under the Apache 2.0 License.
7
+ //
@@ -0,0 +1,7 @@
1
+ //
2
+ // Stub out `require` in rhino
3
+ //
4
+ function require(arg) {
5
+ return less[arg.split('/')[1]];
6
+ };
7
+
@@ -0,0 +1,7 @@
1
+ //
2
+ // Stub out `require` in the browser
3
+ //
4
+ function require(arg) {
5
+ return window.less[arg.split('/')[1]];
6
+ };
7
+