diff --git a/CHANGELOG.md b/CHANGELOG.md index e69de29..af3663d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -0,0 +1,4 @@ +## 1.0.0 +Support less@3 +## 1.0.1 +Move postcss & less to dependencies. \ No newline at end of file diff --git a/index.js b/index.js index 50002f9..2b095ab 100644 --- a/index.js +++ b/index.js @@ -96,8 +96,8 @@ function LessPlugin() { directive: function(directive) { var filename = directive.path - ? directive.path.currentFileInfo.filename - : directive.currentFileInfo.filename; + ? directive.path._fileInfo.filename + : directive._fileInfo.filename; var val, node, nodeTmp = buildNodeObject(filename, directive.index); if(!directive.path) { @@ -152,7 +152,7 @@ function LessPlugin() { if (!(pathSubCnt = path.length)) { continue; } if(i === 0) { - tmpObj = buildNodeObject(ruleset.selectors[0].elements[0].currentFileInfo.filename, ruleset.selectors[0].elements[0].index); + tmpObj = buildNodeObject(ruleset.selectors[0].elements[0]._fileInfo.filename, ruleset.selectors[0].elements[0].index); node = { type: "rule" , nodes: [] @@ -177,7 +177,7 @@ function LessPlugin() { for (i = 0; i < ruleset.selectors.length; i++) { selector = ruleset.selectors[i]; if(i === 0) { - tmpObj = buildNodeObject(selector.elements[0].currentFileInfo.filename, selector.elements[0].index); + tmpObj = buildNodeObject(selector.elements[0]._fileInfo.filename, selector.elements[0].index); node = { type: "rule" , nodes: [] @@ -195,13 +195,17 @@ function LessPlugin() { node.selectors = selectors; - var rule = postcss.rule(node); + var rule = postcss.rule(node); + + // add semicolon + rule.raws.semicolon = true; + processRules(rule, ruleset.rules); return rule; } // PostCSS "decl" , rule: function(rule) { - var node, tmpObj = buildNodeObject(rule.currentFileInfo.filename, rule.index); + var node, tmpObj = buildNodeObject(rule._fileInfo.filename, rule.index); var evalValue = getObject(rule.value, true); node = { @@ -223,13 +227,13 @@ function LessPlugin() { node.important = true; node.value = testImportant[1].trim(); } - } + } return postcss.decl(node); } , comment: function(comment) { - var node, tmpObj = buildNodeObject(comment.currentFileInfo.filename, comment.index); + var node, tmpObj = buildNodeObject(comment._fileInfo.filename, comment.index); node = { type: "comment" @@ -259,32 +263,33 @@ function LessPlugin() { } // a.k.a. PostCSS "decl" - else if(val instanceof less.tree.Rule) { + else if(val instanceof less.tree.Declaration) { container.append(process.rule(val)); } else if(val instanceof less.tree.Comment) { container.append(process.comment(val)); } // a.k.a. PostCSS "atrule" - else if(val instanceof less.tree.Directive) { + else if(val instanceof less.tree.AtRule) { container.append(process.directive(val)); } else if(val instanceof less.tree.Import) { container.append(process.directive(val)); } }); - } + } } - return new Promise(function (resolve, reject) { - cacheInput = cacheInput.toString(); - if(!cacheInput) { - // TODO: explain the error - reject(new CssSyntaxError( - "No input is present" - )); - } - render(cacheInput, opts, function(err, tree, evaldRoot, imports) { + return new Promise(function (resolve, reject) { + + cacheInput = cacheInput.toString(); + if(!cacheInput) { + // TODO: explain the error + reject(new CssSyntaxError( + "No input is present" + )); + } + render(cacheInput, opts, function(err, tree, evaldRoot, imports) { if(err) { // Build PostCSS error return reject(new CssSyntaxError( @@ -302,11 +307,11 @@ function LessPlugin() { context = {}; // Convert Less AST to PostCSS AST convertImports(imports.contents); - + if(isFunction(opts.onImport)){ opts.onImport(Object.keys(postCssInputs)) } - + processRules(css, evaldRoot.rules); resolve(); } diff --git a/package.json b/package.json index cd31744..a9a02f1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "postcss-less-engine", - "version": "0.6.2", + "name": "postcss-less-engine-latest", + "version": "1.0.1", "description": "PostCSS plugin for integrating the popular Less CSS pre-processor into your PostCSS workflow", "keywords": [ "postcss", @@ -16,7 +16,10 @@ "url": "https://github.com/Crunch/postcss-less/issues" }, "homepage": "https://github.com/Crunch/postcss-less", - "dependencies": {}, + "dependencies": { + "postcss": "^5.0.10", + "less": "^3.9.0" + }, "devDependencies": { "autoprefixer": "^6.3.6", "ava": "^0.4.2", @@ -26,9 +29,7 @@ "gulp-mocha": "^2.2.0", "gulp-postcss": "^6.1.1", "gulp-util": "^3.0.7", - "less": "^2.7.1", "less-plugin-future-compat": "^1.0.0", - "postcss": "^5.0.10", "postcss-clean": "^1.0.2", "postcss-reporter": "^1.4.1" },