less 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +4 -0
- data/Gemfile +1 -1
- data/less.gemspec +1 -1
- data/lib/less/defaults.rb +3 -3
- data/lib/less/java_script/v8_context.rb +1 -1
- data/lib/less/js/.gitattributes +3 -2
- data/lib/less/js/.gitignore +18 -2
- data/lib/less/js/.jshintrc +11 -0
- data/lib/less/js/CHANGELOG.md +87 -2
- data/lib/less/js/CONTRIBUTING.md +4 -3
- data/lib/less/js/Gruntfile.js +290 -0
- data/lib/less/js/README.md +342 -12
- data/lib/less/js/benchmark/benchmark.less +194 -194
- data/lib/less/js/benchmark/less-benchmark.js +9 -10
- data/lib/less/js/bin/lessc +154 -12
- data/lib/less/js/bower.json +18 -0
- data/lib/less/js/build.gradle +347 -0
- data/lib/less/js/build/README.md +350 -0
- data/lib/less/js/build/browser-header.js +4 -0
- data/lib/less/js/build/build.yml +160 -0
- data/lib/less/js/build/require-rhino.js +7 -2
- data/lib/less/js/build/rhino-header.js +4 -0
- data/lib/less/js/build/rhino-modules.js +131 -0
- data/lib/less/js/build/tasks/.gitkeep +1 -0
- data/lib/less/js/dist/less-1.5.0.js +6914 -0
- data/lib/less/js/dist/less-1.5.0.min.js +13 -0
- data/lib/less/js/dist/less-1.5.1.js +6941 -0
- data/lib/less/js/dist/less-1.5.1.min.js +13 -0
- data/lib/less/js/dist/less-1.6.0.js +7485 -0
- data/lib/less/js/dist/less-1.6.0.min.js +16 -0
- data/lib/less/js/dist/less-1.6.1.js +7513 -0
- data/lib/less/js/dist/less-1.6.1.min.js +16 -0
- data/lib/less/js/dist/less-1.6.2.js +7624 -0
- data/lib/less/js/dist/less-1.6.2.min.js +16 -0
- data/lib/less/js/dist/less-rhino-1.5.1.js +6831 -0
- data/lib/less/js/dist/less-rhino-1.6.2.js +9017 -0
- data/lib/less/js/dist/lessc-rhino-1.6.2.js +449 -0
- data/lib/less/js/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/lib/less/js/gradle/wrapper/gradle-wrapper.properties +6 -0
- data/lib/less/js/gradlew +164 -0
- data/lib/less/js/gradlew.bat +90 -0
- data/lib/less/js/lib/less/browser.js +482 -367
- data/lib/less/js/lib/less/colors.js +0 -1
- data/lib/less/js/lib/less/encoder.js +4 -0
- data/lib/less/js/lib/less/env.js +50 -19
- data/lib/less/js/lib/less/extend-visitor.js +66 -41
- data/lib/less/js/lib/less/functions.js +309 -104
- data/lib/less/js/lib/less/import-visitor.js +21 -10
- data/lib/less/js/lib/less/index.js +90 -68
- data/lib/less/js/lib/less/join-selector-visitor.js +11 -4
- data/lib/less/js/lib/less/lessc_helper.js +56 -45
- data/lib/less/js/lib/less/parser.js +830 -460
- data/lib/less/js/lib/less/rhino.js +380 -58
- data/lib/less/js/lib/less/source-map-output.js +141 -0
- data/lib/less/js/lib/less/to-css-visitor.js +215 -0
- data/lib/less/js/lib/less/tree.js +57 -5
- data/lib/less/js/lib/less/tree/alpha.js +13 -5
- data/lib/less/js/lib/less/tree/anonymous.js +11 -5
- data/lib/less/js/lib/less/tree/assignment.js +11 -5
- data/lib/less/js/lib/less/tree/call.js +19 -8
- data/lib/less/js/lib/less/tree/color.js +59 -36
- data/lib/less/js/lib/less/tree/comment.js +17 -4
- data/lib/less/js/lib/less/tree/condition.js +3 -3
- data/lib/less/js/lib/less/tree/dimension.js +161 -153
- data/lib/less/js/lib/less/tree/directive.js +39 -18
- data/lib/less/js/lib/less/tree/element.js +41 -18
- data/lib/less/js/lib/less/tree/expression.js +11 -5
- data/lib/less/js/lib/less/tree/extend.js +11 -1
- data/lib/less/js/lib/less/tree/import.js +34 -20
- data/lib/less/js/lib/less/tree/javascript.js +16 -10
- data/lib/less/js/lib/less/tree/keyword.js +5 -2
- data/lib/less/js/lib/less/tree/media.js +39 -22
- data/lib/less/js/lib/less/tree/mixin.js +135 -56
- data/lib/less/js/lib/less/tree/negative.js +4 -2
- data/lib/less/js/lib/less/tree/operation.js +17 -12
- data/lib/less/js/lib/less/tree/paren.js +5 -2
- data/lib/less/js/lib/less/tree/quoted.js +9 -6
- data/lib/less/js/lib/less/tree/rule.js +39 -21
- data/lib/less/js/lib/less/tree/ruleset.js +229 -145
- data/lib/less/js/lib/less/tree/selector.js +101 -34
- data/lib/less/js/lib/less/tree/unicode-descriptor.js +4 -3
- data/lib/less/js/lib/less/tree/url.js +33 -11
- data/lib/less/js/lib/less/tree/value.js +13 -6
- data/lib/less/js/lib/less/tree/variable.js +13 -8
- data/lib/less/js/lib/less/visitor.js +117 -25
- data/lib/less/js/lib/source-map/source-map-0.1.31.js +1933 -0
- data/lib/less/js/lib/source-map/source-map-footer.js +4 -0
- data/lib/less/js/lib/source-map/source-map-header.js +3 -0
- data/lib/less/js/package.json +30 -15
- data/lib/less/js/test/browser/common.js +131 -56
- data/lib/less/js/test/browser/css/global-vars/simple.css +3 -0
- data/lib/less/js/test/browser/css/modify-vars/simple.css +8 -0
- data/lib/less/js/test/browser/css/relative-urls/urls.css +8 -9
- data/lib/less/js/test/browser/css/rootpath-relative/urls.css +0 -1
- data/lib/less/js/test/browser/css/rootpath/urls.css +0 -1
- data/lib/less/js/test/browser/css/urls.css +18 -14
- data/lib/less/js/test/browser/es5.js +27 -0
- data/lib/less/js/test/{less/errors/color-operation-error.less → browser/less/console-errors/test-error.less} +0 -0
- data/lib/less/js/test/browser/less/console-errors/test-error.txt +2 -0
- data/lib/less/js/test/browser/less/global-vars/simple.less +3 -0
- data/lib/less/js/test/browser/less/modify-vars/imports/simple2.less +4 -0
- data/lib/less/js/test/browser/less/modify-vars/simple.less +8 -0
- data/lib/less/js/test/browser/less/relative-urls/urls.less +1 -1
- data/lib/less/js/test/browser/less/rootpath-relative/urls.less +1 -1
- data/lib/less/js/test/browser/less/rootpath/urls.less +1 -1
- data/lib/less/js/test/browser/less/urls.less +9 -1
- data/lib/less/js/test/browser/phantom-runner.js +112 -103
- data/lib/less/js/test/browser/runner-browser-options.js +42 -0
- data/lib/less/js/test/browser/{runner-browser.js → runner-browser-spec.js} +7 -2
- data/lib/less/js/test/browser/runner-console-errors.js +5 -0
- data/lib/less/js/test/browser/runner-errors-options.js +5 -0
- data/lib/less/js/test/browser/runner-errors-spec.js +4 -0
- data/lib/less/js/test/browser/runner-global-vars-options.js +4 -0
- data/lib/less/js/test/browser/runner-global-vars-spec.js +3 -0
- data/lib/less/js/test/browser/runner-legacy-options.js +4 -0
- data/lib/less/js/test/browser/{runner-legacy.js → runner-legacy-spec.js} +1 -4
- data/lib/less/js/test/browser/runner-main-options.js +15 -0
- data/lib/less/js/test/browser/runner-main-spec.js +3 -0
- data/lib/less/js/test/browser/runner-modify-vars-options.js +2 -0
- data/lib/less/js/test/browser/runner-modify-vars-spec.js +43 -0
- data/lib/less/js/test/browser/runner-no-js-errors-options.js +4 -0
- data/lib/less/js/test/browser/runner-no-js-errors-spec.js +4 -0
- data/lib/less/js/test/browser/runner-production-options.js +3 -0
- data/lib/less/js/test/browser/{runner-production.js → runner-production-spec.js} +1 -3
- data/lib/less/js/test/browser/runner-relative-urls-options.js +3 -0
- data/lib/less/js/test/browser/{runner-relative-urls.js → runner-relative-urls-spec.js} +1 -2
- data/lib/less/js/test/browser/runner-rootpath-options.js +3 -0
- data/lib/less/js/test/browser/runner-rootpath-relative-options.js +4 -0
- data/lib/less/js/test/browser/{runner-rootpath-relative.js → runner-rootpath-relative-spec.js} +1 -3
- data/lib/less/js/test/browser/{runner-rootpath.js → runner-rootpath-spec.js} +1 -2
- data/lib/less/js/test/browser/test-runner-template.tmpl +47 -0
- data/lib/less/js/test/css/colors.css +7 -0
- data/lib/less/js/test/css/comments.css +9 -4
- data/lib/less/js/test/css/compression/compression.css +3 -2
- data/lib/less/js/test/css/css-3.css +17 -5
- data/lib/less/js/test/css/css-guards.css +37 -0
- data/lib/less/js/test/css/debug/linenumbers-all.css +6 -0
- data/lib/less/js/test/css/debug/linenumbers-comments.css +5 -0
- data/lib/less/js/test/css/debug/linenumbers-mediaquery.css +5 -0
- data/lib/less/js/test/css/empty.css +0 -0
- data/lib/less/js/test/css/extend-chaining.css +9 -0
- data/lib/less/js/test/css/extend-selector.css +10 -2
- data/lib/less/js/test/css/extract-and-length.css +133 -0
- data/lib/less/js/test/css/functions.css +23 -10
- data/lib/less/js/test/css/globalVars/extended.css +12 -0
- data/lib/less/js/test/css/globalVars/simple.css +6 -0
- data/lib/less/js/test/css/import-inline.css +5 -0
- data/lib/less/js/test/css/import-once.css +12 -0
- data/lib/less/js/test/css/import-reference.css +49 -0
- data/lib/less/js/test/css/import.css +0 -2
- data/lib/less/js/test/css/media.css +21 -5
- data/lib/less/js/test/css/merge.css +26 -0
- data/lib/less/js/test/css/mixins-guards-default-func.css +129 -0
- data/lib/less/js/test/css/mixins-guards.css +6 -0
- data/lib/less/js/test/css/mixins-important.css +7 -0
- data/lib/less/js/test/css/mixins-interpolated.css +39 -0
- data/lib/less/js/test/css/mixins.css +20 -0
- data/lib/less/js/test/css/modifyVars/extended.css +9 -0
- data/lib/less/js/test/css/no-output.css +0 -0
- data/lib/less/js/test/css/parens.css +3 -0
- data/lib/less/js/test/css/property-name-interp.css +20 -0
- data/lib/less/js/test/css/selectors.css +12 -0
- data/lib/less/js/test/css/static-urls/urls.css +7 -4
- data/lib/less/js/test/css/strings.css +3 -0
- data/lib/less/js/test/css/url-args/urls.css +56 -0
- data/lib/less/js/test/css/urls.css +21 -9
- data/lib/less/js/test/index.js +45 -0
- data/lib/less/js/test/less-test.js +234 -191
- data/lib/less/js/test/less/colors.less +6 -0
- data/lib/less/js/test/less/comments.less +7 -1
- data/lib/less/js/test/less/compression/compression.less +21 -1
- data/lib/less/js/test/less/css-3.less +12 -0
- data/lib/less/js/test/less/css-guards.less +99 -0
- data/lib/less/js/test/less/debug/linenumbers.less +11 -1
- data/lib/less/js/test/less/empty.less +0 -0
- data/lib/less/js/test/less/errors/add-mixed-units.txt +4 -2
- data/lib/less/js/test/less/errors/add-mixed-units2.txt +4 -2
- data/lib/less/js/test/less/errors/color-func-invalid-color.less +3 -0
- data/lib/less/js/test/less/errors/color-func-invalid-color.txt +4 -0
- data/lib/less/js/test/less/errors/css-guard-default-func.less +4 -0
- data/lib/less/js/test/less/errors/css-guard-default-func.txt +4 -0
- data/lib/less/js/test/less/errors/import-subfolder2.txt +4 -2
- data/lib/less/js/test/less/errors/javascript-undefined-var.less +3 -0
- data/lib/less/js/test/less/errors/javascript-undefined-var.txt +4 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-1.less +9 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-1.txt +4 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-2.less +9 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-2.txt +4 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-3.less +9 -0
- data/lib/less/js/test/less/errors/mixins-guards-default-func-3.txt +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors.less +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors.txt +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors2.less +4 -0
- data/lib/less/js/test/less/errors/multiple-guards-on-css-selectors2.txt +4 -0
- data/lib/less/js/test/less/errors/parse-error-curly-bracket.less +4 -1
- data/lib/less/js/test/less/errors/parse-error-curly-bracket.txt +4 -2
- data/lib/less/js/test/less/errors/parse-error-extra-parens.less +5 -0
- data/lib/less/js/test/less/errors/parse-error-extra-parens.txt +3 -0
- data/lib/less/js/test/less/errors/parse-error-missing-bracket.txt +2 -2
- data/lib/less/js/test/less/errors/parse-error-missing-parens.less +5 -0
- data/lib/less/js/test/less/errors/parse-error-missing-parens.txt +3 -0
- data/lib/less/js/test/less/errors/property-asterisk-only-name.less +3 -0
- data/lib/less/js/test/less/errors/property-asterisk-only-name.txt +4 -0
- data/lib/less/js/test/less/errors/property-interp-not-defined.less +1 -0
- data/lib/less/js/test/less/errors/property-interp-not-defined.txt +2 -0
- data/lib/less/js/test/less/errors/svg-gradient1.less +3 -0
- data/lib/less/js/test/less/errors/svg-gradient1.txt +4 -0
- data/lib/less/js/test/less/errors/svg-gradient2.less +3 -0
- data/lib/less/js/test/less/errors/svg-gradient2.txt +4 -0
- data/lib/less/js/test/less/errors/svg-gradient3.less +3 -0
- data/lib/less/js/test/less/errors/svg-gradient3.txt +4 -0
- data/lib/less/js/test/less/errors/unit-function.less +3 -0
- data/lib/less/js/test/less/errors/unit-function.txt +4 -0
- data/lib/less/js/test/less/extend-chaining.less +12 -0
- data/lib/less/js/test/less/extend-selector.less +15 -0
- data/lib/less/js/test/less/extract-and-length.less +133 -0
- data/lib/less/js/test/less/functions.less +15 -2
- data/lib/less/js/test/less/globalVars/extended.json +5 -0
- data/lib/less/js/test/less/globalVars/extended.less +10 -0
- data/lib/less/js/test/less/globalVars/simple.json +3 -0
- data/lib/less/js/test/less/globalVars/simple.less +3 -0
- data/lib/less/js/test/less/import-inline.less +2 -0
- data/lib/less/js/test/less/import-once.less +2 -0
- data/lib/less/js/test/less/import-reference.less +18 -0
- data/lib/less/js/test/less/import/import-and-relative-paths-test.less +11 -0
- data/lib/less/js/test/less/import/import-reference.less +43 -0
- data/lib/less/js/test/less/import/import-test-f.less +5 -0
- data/lib/less/js/test/less/import/invalid-css.less +1 -0
- data/lib/less/js/test/less/media.less +25 -1
- data/lib/less/js/test/less/merge.less +59 -0
- data/lib/less/js/test/less/mixins-args.less +10 -0
- data/lib/less/js/test/less/mixins-guards-default-func.less +195 -0
- data/lib/less/js/test/less/mixins-guards.less +16 -0
- data/lib/less/js/test/less/mixins-important.less +4 -1
- data/lib/less/js/test/less/mixins-interpolated.less +69 -0
- data/lib/less/js/test/less/mixins.less +27 -0
- data/lib/less/js/test/less/modifyVars/extended.json +5 -0
- data/lib/less/js/test/less/modifyVars/extended.less +11 -0
- data/lib/less/js/test/less/no-js-errors/no-js-errors.less +3 -0
- data/lib/less/js/test/less/no-js-errors/no-js-errors.txt +4 -0
- data/lib/less/js/test/less/no-output.less +2 -0
- data/lib/less/js/test/less/parens.less +4 -0
- data/lib/less/js/test/less/property-name-interp.less +53 -0
- data/lib/less/js/test/less/selectors.less +13 -0
- data/lib/less/js/test/less/sourcemaps/basic.json +3 -0
- data/lib/less/js/test/less/sourcemaps/basic.less +27 -0
- data/lib/less/js/test/less/sourcemaps/imported.css +7 -0
- data/lib/less/js/test/less/strings.less +6 -0
- data/lib/less/js/test/less/url-args/urls.less +63 -0
- data/lib/less/js/test/less/urls.less +15 -0
- data/lib/less/js/test/rhino/test-header.js +15 -0
- data/lib/less/js/test/sourcemaps/basic.json +1 -0
- data/lib/less/js/test/sourcemaps/index.html +17 -0
- data/lib/less/loader.rb +48 -40
- data/lib/less/version.rb +1 -1
- data/spec/less/parser_spec.rb +15 -15
- metadata +146 -40
- data/lib/less/js/Makefile +0 -102
- data/lib/less/js/build/header.js +0 -9
- data/lib/less/js/test/browser-test-prepare.js +0 -46
- data/lib/less/js/test/browser/runner-errors.js +0 -5
- data/lib/less/js/test/browser/runner-main.js +0 -15
- data/lib/less/js/test/browser/template.htm +0 -10
- data/lib/less/js/test/less/errors/color-operation-error.txt +0 -2
@@ -0,0 +1,449 @@
|
|
1
|
+
/* LESS.js v1.6.2 RHINO | Copyright (c) 2009-2014, Alexis Sellier <self@cloudhead.net> */
|
2
|
+
|
3
|
+
/*global name:true, less, loadStyleSheet, os */
|
4
|
+
|
5
|
+
function formatError(ctx, options) {
|
6
|
+
options = options || {};
|
7
|
+
|
8
|
+
var message = "";
|
9
|
+
var extract = ctx.extract;
|
10
|
+
var error = [];
|
11
|
+
|
12
|
+
// var stylize = options.color ? require('./lessc_helper').stylize : function (str) { return str; };
|
13
|
+
var stylize = function (str) { return str; };
|
14
|
+
|
15
|
+
// only output a stack if it isn't a less error
|
16
|
+
if (ctx.stack && !ctx.type) { return stylize(ctx.stack, 'red'); }
|
17
|
+
|
18
|
+
if (!ctx.hasOwnProperty('index') || !extract) {
|
19
|
+
return ctx.stack || ctx.message;
|
20
|
+
}
|
21
|
+
|
22
|
+
if (typeof(extract[0]) === 'string') {
|
23
|
+
error.push(stylize((ctx.line - 1) + ' ' + extract[0], 'grey'));
|
24
|
+
}
|
25
|
+
|
26
|
+
if (typeof(extract[1]) === 'string') {
|
27
|
+
var errorTxt = ctx.line + ' ';
|
28
|
+
if (extract[1]) {
|
29
|
+
errorTxt += extract[1].slice(0, ctx.column) +
|
30
|
+
stylize(stylize(stylize(extract[1][ctx.column], 'bold') +
|
31
|
+
extract[1].slice(ctx.column + 1), 'red'), 'inverse');
|
32
|
+
}
|
33
|
+
error.push(errorTxt);
|
34
|
+
}
|
35
|
+
|
36
|
+
if (typeof(extract[2]) === 'string') {
|
37
|
+
error.push(stylize((ctx.line + 1) + ' ' + extract[2], 'grey'));
|
38
|
+
}
|
39
|
+
error = error.join('\n') + stylize('', 'reset') + '\n';
|
40
|
+
|
41
|
+
message += stylize(ctx.type + 'Error: ' + ctx.message, 'red');
|
42
|
+
if (ctx.filename) {
|
43
|
+
message += stylize(' in ', 'red') + ctx.filename +
|
44
|
+
stylize(' on line ' + ctx.line + ', column ' + (ctx.column + 1) + ':', 'grey');
|
45
|
+
}
|
46
|
+
|
47
|
+
message += '\n' + error;
|
48
|
+
|
49
|
+
if (ctx.callLine) {
|
50
|
+
message += stylize('from ', 'red') + (ctx.filename || '') + '/n';
|
51
|
+
message += stylize(ctx.callLine, 'grey') + ' ' + ctx.callExtract + '/n';
|
52
|
+
}
|
53
|
+
|
54
|
+
return message;
|
55
|
+
}
|
56
|
+
|
57
|
+
function writeError(ctx, options) {
|
58
|
+
options = options || {};
|
59
|
+
if (options.silent) { return; }
|
60
|
+
print(formatError(ctx, options));
|
61
|
+
}
|
62
|
+
|
63
|
+
function loadStyleSheet(sheet, callback, reload, remaining) {
|
64
|
+
var endOfPath = Math.max(name.lastIndexOf('/'), name.lastIndexOf('\\')),
|
65
|
+
sheetName = name.slice(0, endOfPath + 1) + sheet.href,
|
66
|
+
contents = sheet.contents || {},
|
67
|
+
input = readFile(sheetName);
|
68
|
+
|
69
|
+
input = input.replace(/^\xEF\xBB\xBF/, '');
|
70
|
+
|
71
|
+
contents[sheetName] = input;
|
72
|
+
|
73
|
+
var parser = new less.Parser({
|
74
|
+
paths: [sheet.href.replace(/[\w\.-]+$/, '')],
|
75
|
+
contents: contents
|
76
|
+
});
|
77
|
+
parser.parse(input, function (e, root) {
|
78
|
+
if (e) {
|
79
|
+
return writeError(e);
|
80
|
+
}
|
81
|
+
try {
|
82
|
+
callback(e, root, input, sheet, { local: false, lastModified: 0, remaining: remaining }, sheetName);
|
83
|
+
} catch(e) {
|
84
|
+
writeError(e);
|
85
|
+
}
|
86
|
+
});
|
87
|
+
}
|
88
|
+
|
89
|
+
less.Parser.fileLoader = function (file, currentFileInfo, callback, env) {
|
90
|
+
|
91
|
+
var href = file;
|
92
|
+
if (currentFileInfo && currentFileInfo.currentDirectory && !/^\//.test(file)) {
|
93
|
+
href = less.modules.path.join(currentFileInfo.currentDirectory, file);
|
94
|
+
}
|
95
|
+
|
96
|
+
var path = less.modules.path.dirname(href);
|
97
|
+
|
98
|
+
var newFileInfo = {
|
99
|
+
currentDirectory: path + '/',
|
100
|
+
filename: href
|
101
|
+
};
|
102
|
+
|
103
|
+
if (currentFileInfo) {
|
104
|
+
newFileInfo.entryPath = currentFileInfo.entryPath;
|
105
|
+
newFileInfo.rootpath = currentFileInfo.rootpath;
|
106
|
+
newFileInfo.rootFilename = currentFileInfo.rootFilename;
|
107
|
+
newFileInfo.relativeUrls = currentFileInfo.relativeUrls;
|
108
|
+
} else {
|
109
|
+
newFileInfo.entryPath = path;
|
110
|
+
newFileInfo.rootpath = less.rootpath || path;
|
111
|
+
newFileInfo.rootFilename = href;
|
112
|
+
newFileInfo.relativeUrls = env.relativeUrls;
|
113
|
+
}
|
114
|
+
|
115
|
+
var j = file.lastIndexOf('/');
|
116
|
+
if(newFileInfo.relativeUrls && !/^(?:[a-z-]+:|\/)/.test(file) && j != -1) {
|
117
|
+
var relativeSubDirectory = file.slice(0, j+1);
|
118
|
+
newFileInfo.rootpath = newFileInfo.rootpath + relativeSubDirectory; // append (sub|sup) directory path of imported file
|
119
|
+
}
|
120
|
+
newFileInfo.currentDirectory = path;
|
121
|
+
newFileInfo.filename = href;
|
122
|
+
|
123
|
+
var data = null;
|
124
|
+
try {
|
125
|
+
data = readFile(href);
|
126
|
+
} catch (e) {
|
127
|
+
callback({ type: 'File', message: "'" + less.modules.path.basename(href) + "' wasn't found" });
|
128
|
+
return;
|
129
|
+
}
|
130
|
+
|
131
|
+
try {
|
132
|
+
callback(null, data, href, newFileInfo, { lastModified: 0 });
|
133
|
+
} catch (e) {
|
134
|
+
callback(e, null, href);
|
135
|
+
}
|
136
|
+
};
|
137
|
+
|
138
|
+
|
139
|
+
function writeFile(filename, content) {
|
140
|
+
var fstream = new java.io.FileWriter(filename);
|
141
|
+
var out = new java.io.BufferedWriter(fstream);
|
142
|
+
out.write(content);
|
143
|
+
out.close();
|
144
|
+
}
|
145
|
+
|
146
|
+
// Command line integration via Rhino
|
147
|
+
(function (args) {
|
148
|
+
|
149
|
+
var options = {
|
150
|
+
depends: false,
|
151
|
+
compress: false,
|
152
|
+
cleancss: false,
|
153
|
+
max_line_len: -1,
|
154
|
+
optimization: 1,
|
155
|
+
silent: false,
|
156
|
+
verbose: false,
|
157
|
+
lint: false,
|
158
|
+
paths: [],
|
159
|
+
color: true,
|
160
|
+
strictImports: false,
|
161
|
+
rootpath: '',
|
162
|
+
relativeUrls: false,
|
163
|
+
ieCompat: true,
|
164
|
+
strictMath: false,
|
165
|
+
strictUnits: false
|
166
|
+
};
|
167
|
+
var continueProcessing = true,
|
168
|
+
currentErrorcode;
|
169
|
+
|
170
|
+
var checkArgFunc = function(arg, option) {
|
171
|
+
if (!option) {
|
172
|
+
print(arg + " option requires a parameter");
|
173
|
+
continueProcessing = false;
|
174
|
+
return false;
|
175
|
+
}
|
176
|
+
return true;
|
177
|
+
};
|
178
|
+
|
179
|
+
var checkBooleanArg = function(arg) {
|
180
|
+
var onOff = /^((on|t|true|y|yes)|(off|f|false|n|no))$/i.exec(arg);
|
181
|
+
if (!onOff) {
|
182
|
+
print(" unable to parse "+arg+" as a boolean. use one of on/t/true/y/yes/off/f/false/n/no");
|
183
|
+
continueProcessing = false;
|
184
|
+
return false;
|
185
|
+
}
|
186
|
+
return Boolean(onOff[2]);
|
187
|
+
};
|
188
|
+
|
189
|
+
var warningMessages = "";
|
190
|
+
var sourceMapFileInline = false;
|
191
|
+
|
192
|
+
args = args.filter(function (arg) {
|
193
|
+
var match = arg.match(/^-I(.+)$/);
|
194
|
+
|
195
|
+
if (match) {
|
196
|
+
options.paths.push(match[1]);
|
197
|
+
return false;
|
198
|
+
}
|
199
|
+
|
200
|
+
match = arg.match(/^--?([a-z][0-9a-z-]*)(?:=(.*))?$/i);
|
201
|
+
if (match) { arg = match[1]; } // was (?:=([^\s]*)), check!
|
202
|
+
else { return arg; }
|
203
|
+
|
204
|
+
switch (arg) {
|
205
|
+
case 'v':
|
206
|
+
case 'version':
|
207
|
+
console.log("lessc " + less.version.join('.') + " (LESS Compiler) [JavaScript]");
|
208
|
+
continueProcessing = false;
|
209
|
+
break;
|
210
|
+
case 'verbose':
|
211
|
+
options.verbose = true;
|
212
|
+
break;
|
213
|
+
case 's':
|
214
|
+
case 'silent':
|
215
|
+
options.silent = true;
|
216
|
+
break;
|
217
|
+
case 'l':
|
218
|
+
case 'lint':
|
219
|
+
options.lint = true;
|
220
|
+
break;
|
221
|
+
case 'strict-imports':
|
222
|
+
options.strictImports = true;
|
223
|
+
break;
|
224
|
+
case 'h':
|
225
|
+
case 'help':
|
226
|
+
//TODO
|
227
|
+
// require('../lib/less/lessc_helper').printUsage();
|
228
|
+
continueProcessing = false;
|
229
|
+
break;
|
230
|
+
case 'x':
|
231
|
+
case 'compress':
|
232
|
+
options.compress = true;
|
233
|
+
break;
|
234
|
+
case 'M':
|
235
|
+
case 'depends':
|
236
|
+
options.depends = true;
|
237
|
+
break;
|
238
|
+
case 'yui-compress':
|
239
|
+
warningMessages += "yui-compress option has been removed. assuming clean-css.";
|
240
|
+
options.cleancss = true;
|
241
|
+
break;
|
242
|
+
case 'clean-css':
|
243
|
+
options.cleancss = true;
|
244
|
+
break;
|
245
|
+
case 'max-line-len':
|
246
|
+
if (checkArgFunc(arg, match[2])) {
|
247
|
+
options.maxLineLen = parseInt(match[2], 10);
|
248
|
+
if (options.maxLineLen <= 0) {
|
249
|
+
options.maxLineLen = -1;
|
250
|
+
}
|
251
|
+
}
|
252
|
+
break;
|
253
|
+
case 'no-color':
|
254
|
+
options.color = false;
|
255
|
+
break;
|
256
|
+
case 'no-ie-compat':
|
257
|
+
options.ieCompat = false;
|
258
|
+
break;
|
259
|
+
case 'no-js':
|
260
|
+
options.javascriptEnabled = false;
|
261
|
+
break;
|
262
|
+
case 'include-path':
|
263
|
+
if (checkArgFunc(arg, match[2])) {
|
264
|
+
options.paths = match[2].split(os.type().match(/Windows/) ? ';' : ':')
|
265
|
+
.map(function(p) {
|
266
|
+
if (p) {
|
267
|
+
// return path.resolve(process.cwd(), p);
|
268
|
+
return p;
|
269
|
+
}
|
270
|
+
});
|
271
|
+
}
|
272
|
+
break;
|
273
|
+
case 'O0': options.optimization = 0; break;
|
274
|
+
case 'O1': options.optimization = 1; break;
|
275
|
+
case 'O2': options.optimization = 2; break;
|
276
|
+
case 'line-numbers':
|
277
|
+
if (checkArgFunc(arg, match[2])) {
|
278
|
+
options.dumpLineNumbers = match[2];
|
279
|
+
}
|
280
|
+
break;
|
281
|
+
case 'source-map':
|
282
|
+
if (!match[2]) {
|
283
|
+
options.sourceMap = true;
|
284
|
+
} else {
|
285
|
+
options.sourceMap = match[2];
|
286
|
+
}
|
287
|
+
break;
|
288
|
+
case 'source-map-rootpath':
|
289
|
+
if (checkArgFunc(arg, match[2])) {
|
290
|
+
options.sourceMapRootpath = match[2];
|
291
|
+
}
|
292
|
+
break;
|
293
|
+
case 'source-map-basepath':
|
294
|
+
if (checkArgFunc(arg, match[2])) {
|
295
|
+
options.sourceMapBasepath = match[2];
|
296
|
+
}
|
297
|
+
break;
|
298
|
+
case 'source-map-map-inline':
|
299
|
+
sourceMapFileInline = true;
|
300
|
+
options.sourceMap = true;
|
301
|
+
break;
|
302
|
+
case 'source-map-less-inline':
|
303
|
+
options.outputSourceFiles = true;
|
304
|
+
break;
|
305
|
+
case 'source-map-url':
|
306
|
+
if (checkArgFunc(arg, match[2])) {
|
307
|
+
options.sourceMapURL = match[2];
|
308
|
+
}
|
309
|
+
break;
|
310
|
+
case 'source-map-output-map-file':
|
311
|
+
if (checkArgFunc(arg, match[2])) {
|
312
|
+
options.writeSourceMap = function(sourceMapContent) {
|
313
|
+
writeFile(match[2], sourceMapContent);
|
314
|
+
};
|
315
|
+
}
|
316
|
+
break;
|
317
|
+
case 'rp':
|
318
|
+
case 'rootpath':
|
319
|
+
if (checkArgFunc(arg, match[2])) {
|
320
|
+
options.rootpath = match[2].replace(/\\/g, '/');
|
321
|
+
}
|
322
|
+
break;
|
323
|
+
case "ru":
|
324
|
+
case "relative-urls":
|
325
|
+
options.relativeUrls = true;
|
326
|
+
break;
|
327
|
+
case "sm":
|
328
|
+
case "strict-math":
|
329
|
+
if (checkArgFunc(arg, match[2])) {
|
330
|
+
options.strictMath = checkBooleanArg(match[2]);
|
331
|
+
}
|
332
|
+
break;
|
333
|
+
case "su":
|
334
|
+
case "strict-units":
|
335
|
+
if (checkArgFunc(arg, match[2])) {
|
336
|
+
options.strictUnits = checkBooleanArg(match[2]);
|
337
|
+
}
|
338
|
+
break;
|
339
|
+
default:
|
340
|
+
console.log('invalid option ' + arg);
|
341
|
+
continueProcessing = false;
|
342
|
+
}
|
343
|
+
});
|
344
|
+
|
345
|
+
if (!continueProcessing) {
|
346
|
+
return;
|
347
|
+
}
|
348
|
+
|
349
|
+
var name = args[0];
|
350
|
+
if (name && name != '-') {
|
351
|
+
// name = path.resolve(process.cwd(), name);
|
352
|
+
}
|
353
|
+
var output = args[1];
|
354
|
+
var outputbase = args[1];
|
355
|
+
if (output) {
|
356
|
+
options.sourceMapOutputFilename = output;
|
357
|
+
// output = path.resolve(process.cwd(), output);
|
358
|
+
if (warningMessages) {
|
359
|
+
console.log(warningMessages);
|
360
|
+
}
|
361
|
+
}
|
362
|
+
|
363
|
+
// options.sourceMapBasepath = process.cwd();
|
364
|
+
// options.sourceMapBasepath = '';
|
365
|
+
|
366
|
+
if (options.sourceMap === true) {
|
367
|
+
console.log("output: " + output);
|
368
|
+
if (!output && !sourceMapFileInline) {
|
369
|
+
console.log("the sourcemap option only has an optional filename if the css filename is given");
|
370
|
+
return;
|
371
|
+
}
|
372
|
+
options.sourceMapFullFilename = options.sourceMapOutputFilename + ".map";
|
373
|
+
options.sourceMap = less.modules.path.basename(options.sourceMapFullFilename);
|
374
|
+
} else if (options.sourceMap) {
|
375
|
+
options.sourceMapOutputFilename = options.sourceMap;
|
376
|
+
}
|
377
|
+
|
378
|
+
|
379
|
+
if (!name) {
|
380
|
+
console.log("lessc: no inout files");
|
381
|
+
console.log("");
|
382
|
+
// TODO
|
383
|
+
// require('../lib/less/lessc_helper').printUsage();
|
384
|
+
currentErrorcode = 1;
|
385
|
+
return;
|
386
|
+
}
|
387
|
+
|
388
|
+
// var ensureDirectory = function (filepath) {
|
389
|
+
// var dir = path.dirname(filepath),
|
390
|
+
// cmd,
|
391
|
+
// existsSync = fs.existsSync || path.existsSync;
|
392
|
+
// if (!existsSync(dir)) {
|
393
|
+
// if (mkdirp === undefined) {
|
394
|
+
// try {mkdirp = require('mkdirp');}
|
395
|
+
// catch(e) { mkdirp = null; }
|
396
|
+
// }
|
397
|
+
// cmd = mkdirp && mkdirp.sync || fs.mkdirSync;
|
398
|
+
// cmd(dir);
|
399
|
+
// }
|
400
|
+
// };
|
401
|
+
|
402
|
+
if (options.depends) {
|
403
|
+
if (!outputbase) {
|
404
|
+
console.log("option --depends requires an output path to be specified");
|
405
|
+
return;
|
406
|
+
}
|
407
|
+
console.log(outputbase + ": ");
|
408
|
+
}
|
409
|
+
|
410
|
+
if (!name) {
|
411
|
+
console.log('No files present in the fileset');
|
412
|
+
quit(1);
|
413
|
+
}
|
414
|
+
|
415
|
+
var input = null;
|
416
|
+
try {
|
417
|
+
input = readFile(name, 'utf-8');
|
418
|
+
|
419
|
+
} catch (e) {
|
420
|
+
console.log('lesscss: couldn\'t open file ' + name);
|
421
|
+
quit(1);
|
422
|
+
}
|
423
|
+
|
424
|
+
options.filename = name;
|
425
|
+
var result;
|
426
|
+
try {
|
427
|
+
var parser = new less.Parser(options);
|
428
|
+
parser.parse(input, function (e, root) {
|
429
|
+
if (e) {
|
430
|
+
writeError(e, options);
|
431
|
+
quit(1);
|
432
|
+
} else {
|
433
|
+
result = root.toCSS(options);
|
434
|
+
if (output) {
|
435
|
+
writeFile(output, result);
|
436
|
+
console.log("Written to " + output);
|
437
|
+
} else {
|
438
|
+
print(result);
|
439
|
+
}
|
440
|
+
quit(0);
|
441
|
+
}
|
442
|
+
});
|
443
|
+
}
|
444
|
+
catch(e) {
|
445
|
+
writeError(e, options);
|
446
|
+
quit(1);
|
447
|
+
}
|
448
|
+
console.log("done");
|
449
|
+
}(arguments));
|
Binary file
|