Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' into output-format

  • Loading branch information...
commit 0bddc3a071e20818b564101794b340b9683eb7fb 2 parents d2db463 + 6316cc3
@illusori illusori authored
View
8 .gitattributes
@@ -0,0 +1,8 @@
+# Set default behaviour, in case users don't have core.autocrlf set.
+* text=lf
+* text eol=lf
+*.* eol=lf
+
+*.png binary
+*.jpg binary
+*.gif binary
View
3  .travis.yml
@@ -1,4 +1,3 @@
language: node_js
node_js:
- - 0.4
- - 0.6
+ - 0.8
View
2  README.md
@@ -23,6 +23,7 @@ OPTIONS
- --format text - the default format, shows errors and context
- --format compact - show errors one-error-per-line, useful for IDE integration
- --noSummary - don't output the summary block for each file
+- --includePath - accepts an additional directory path to look for `@import`:ed LESS files in.
- --stripColors - removes color from output (useful when logging)
- --watch - watch filesystem for changes, useful when compiling Less projects
- --noIDs - doesn't complain about using IDs in your stylesheets
@@ -93,6 +94,7 @@ The following options (and defaults) are available in the programatic api:
- compile: false
- compress: false
+- includePath: []
- noIDs: true
- noJSPrefix: true
- noOverqualifying: true
View
10 bin/recess
@@ -19,6 +19,7 @@ options = {
, compress: Boolean
, config: path
, format: String
+, includePath: [path, Array]
, noIDs: Boolean
, noJSPrefix: Boolean
, noOverqualifying: Boolean
@@ -27,16 +28,22 @@ options = {
, noUniversalSelectors: Boolean
, prefixWhitespace: Boolean
, strictPropertyOrder: Boolean
+, version: Boolean
, watch: path
, zeroUnits: Boolean
}
// parse options
-options = nopt(options, {}, process.argv)
+shorthand = { 'v': ['--version'] };
+options = nopt(options, shorthand, process.argv)
// if help exit
if (options.help) return recess.docs()
+// set version
+recess.version = require(path.join(__dirname, '..', 'package.json')).version
+if (options.version) return console.log(recess.version)
+
// set path from remaining arguments
paths = options.argv.remain
@@ -53,6 +60,7 @@ if (options.config || (fs.existsSync || path.existsSync)(config)) {
// set CLI to true
options.cli = true
+
// if not watch - run Recess
if (!options.watch) return recess(paths, options)
View
2  lib/compile/inline-images.js
@@ -26,7 +26,7 @@ function compile () {
, mimetype = 'image/' + ext.replace(/jpg/, 'jpeg')
, pathParts = path.split(seperator)
, filePath = pathParts.slice(0, pathParts.length - 1).join(seperator)
- , imgBuffer = new Buffer(fs.readFileSync(filePath+seperator+fileName)).toString('base64')
+ , imgBuffer = new Buffer(fs.readFileSync((filePath?filePath:'.')+seperator+fileName)).toString('base64')
, urlData = 'url(data:' + mimetype + ';base64,' + imgBuffer + ')'
return props.replace(/url\([^\)]*\)/, urlData)
View
2  lib/compile/prefix-whitespace.js
@@ -54,7 +54,7 @@ function space(rules, i) {
peekRoot = peek.name.replace(VENDOR_PREFIX, '')
- // if they share the same root calculte the offset in spacing
+ // if they share the same root calculate the offset in spacing
if (ruleRoot === peekRoot) {
// calculate the rules val
View
13 lib/core.js
@@ -51,7 +51,7 @@ RECESS.prototype = {
// if err, exit with could not read message
if (err) {
that.errors.push(err)
- that.log('Error reading file: '.red + that.path.grey + '\n', true)
+ that.log('Error reading file: '.red + String(that.path).grey + '\n', true)
return that.callback && that.callback()
}
@@ -67,7 +67,7 @@ RECESS.prototype = {
, parse: function () {
var that = this
, options = {
- paths: [path.dirname(this.path)]
+ paths: [path.dirname(this.path)].concat(this.options.includePath)
, optimization: 0
, filename: this.path && this.path.replace(/.*(?=\/)\//, '')
}
@@ -85,8 +85,13 @@ RECESS.prototype = {
// push to errors array
that.errors.push(err)
- // less gave up trying to parse the data ;_;
- that.log(err.name.red + ": " + err.message + ' of ' + err.filename.yellow + '\n')
+ if (err.type == 'Parse') {
+ // parse error
+ that.log("Parser error".red + (err.filename ? ' in ' + err.filename : '') + '\n')
+ } else {
+ // other exception
+ that.log(String(err.name).red + ": " + err.message + ' of ' + String(err.filename).yellow + '\n')
+ }
// if extract - then log it
err.extract && err.extract.forEach(function (line, index) {
View
7 lib/index.js
@@ -45,7 +45,7 @@ module.exports = function (paths, options, callback) {
// for each path, create a new RECESS instance
function recess(init, path, err) {
- if (path = paths.pop()) {
+ if (path = paths.shift()) {
return instances.push(new RECESS(path, options, recess))
}
@@ -62,7 +62,7 @@ module.exports = function (paths, options, callback) {
err = err.length ? err[0] : null
//callback
- callback && callback(err, instances.length > 1 ? instances : instances[0])
+ callback && callback(err, instances)
}
// start processing paths
@@ -75,6 +75,7 @@ module.exports.DEFAULTS = RECESS.DEFAULTS = {
, compress: false
, config: false
, format: 'text'
+, includePath: []
, noIDs: true
, noJSPrefix: true
, noOverqualifying: true
@@ -100,4 +101,4 @@ module.exports.docs = function () {
for (var option in RECESS.DEFAULTS) console.log(' --' + option)
console.log("\nEXAMPLE:\n\n" + " $".grey + " recess".cyan + " ./bootstrap.css ".yellow + "--noIDs false\n".grey)
console.log('GENERAL HELP: ' + 'http://git.io/recess\n'.yellow)
-}
+}
View
2  lib/lint/strict-property-order.js
@@ -74,6 +74,7 @@ var _ = require('underscore')
, 'font-smoothing'
, 'font-style'
, 'font-weight'
+ , 'hyphens'
, 'src'
, 'line-height'
, 'letter-spacing'
@@ -111,6 +112,7 @@ var _ = require('underscore')
, 'border-bottom'
, 'border-left'
, 'border-color'
+ , 'border-image'
, 'border-top-color'
, 'border-right-color'
, 'border-bottom-color'
View
5 package.json
@@ -1,13 +1,14 @@
{ "name": "recess"
, "description": "A simple, attractive code quality tool for CSS built on top of LESS"
-, "version": "1.1.4"
+, "version": "1.1.8"
, "author": "Jacob Thornton <jacob@twitter.com> (https://github.com/fat)"
+, "repository": { "type": "git", "url": "git://github.com/twitter/recess.git" }
, "keywords": ["css", "lint"]
, "licenses": [ { "type": "Apache-2.0", "url": "http://www.apache.org/licenses/LICENSE-2.0" } ]
, "main": "./lib"
, "homepage": "http://twitter.github.com/recess"
, "engines": { "node": ">= 0.4.0" }
-, "dependencies": { "colors": ">= 0.3.0", "nopt": ">= 1.0.10", "underscore": ">= 1.2.1", "watch": ">= 0.5.1", "less": ">= 1.3.0" }
+, "dependencies": { "colors": ">= 0.3.0", "nopt": ">= 1.0.10", "underscore": ">= 1.2.1", "watch": ">= 0.5.1", "less": "~1.3.0" }
, "directories": { "bin": "./bin" }
, "scripts": { "test": "node test" }
, "bin": { "recess": "./bin/recess" }
View
3  test/compiled/zero-units.css
@@ -1,9 +1,6 @@
div {
position: absolute;
margin: 0;
- margin: 0;
- margin: 0;
- margin: 0;
margin: 0 auto;
margin: 0 2px 3px;
color: rgba(0, 0, 0, 0.3);
View
4 test/types/compile.js
@@ -12,9 +12,9 @@ fs.readdirSync('test/fixtures').forEach(function (file, index) {
RECESS('test/fixtures/' + file, { compile: true, inlineImages: true }, function (err, fat) {
file = file.replace(/less$/, 'css')
assert.ok(err == null)
- assert.ok(fat.output[0] == fs.readFileSync('test/compiled/' + file, 'utf-8'))
+ assert.ok(fat[0].output[0] == fs.readFileSync('test/compiled/' + file, 'utf-8'))
})
})
-console.log("✓ compiling".green)
+console.log("✓ compiling".green)
View
33 test/types/lint.js
@@ -231,6 +231,24 @@ var assert = require('assert')
}()
+// Cannot read property 'red' of undefined
+!function () {
+
+ var Recess = new RECESS.Constructor()
+ , validate = RECESS.Constructor.prototype.validate
+
+ RECESS.Constructor.prototype.validate = noop
+
+ Recess.data = ".foo { background:green;; }"
+
+ Recess.parse()
+
+ assert.notEqual(Recess.output[0], '\u001b[31mParse error\u001b[39m: Cannot read property \'red\' of undefined on line 1');
+
+ RECESS.Constructor.prototype.validate = validate
+
+}()
+
//VALIDATIONS.inlineImage
!function () {
@@ -265,4 +283,17 @@ var assert = require('assert')
}()
-console.log("✓ linting".green)
+// Keep order of input paths
+!function () {
+
+ RECESS([
+ 'test/fixtures/blog.css',
+ 'test/fixtures/inline-images.css'
+ ], function (err, instance) {
+ assert(instance[0].path === 'test/fixtures/blog.css');
+ })
+
+}()
+
+
+console.log("✓ linting".green)
Please sign in to comment.
Something went wrong with that request. Please try again.