gulp-compass
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -9,8 +9,3 @@ var es = require('event-stream'), | ||
var filepath = file.path; | ||
compass(filepath, opt, function (error, stdout, stderr) { | ||
console.log(stdout); | ||
if (error !== null) { | ||
gutil.log('exec error: ' + error); | ||
} | ||
}); | ||
compass(filepath, opt); | ||
cb(null, file); | ||
@@ -17,0 +12,0 @@ } |
'use strict'; | ||
var exec = require('child_process').exec, | ||
var spawn = require('child_process').spawn, | ||
gutil = require('gulp-util'), | ||
path = require('path'), | ||
os = require('os'); | ||
os = require('os'), | ||
defaults = { | ||
style: 'nested', | ||
comments: true, | ||
relative: true, | ||
css: 'css', | ||
sass: 'sass', | ||
image: 'images', | ||
config_file: false, | ||
project: process.cwd() | ||
}; | ||
module.exports = function(file, options, callback) { | ||
options = options || {}; | ||
options.cwd = options.cwd || process.cwd(); | ||
module.exports = function(file, opts) { | ||
opts = opts || {}; | ||
opts.cwd = opts.cwd || process.cwd(); | ||
for (var key in defaults) { | ||
if (opts[key] === undefined) { | ||
opts[key] = defaults[key]; | ||
} | ||
} | ||
var compassExecutable = 'compass', | ||
file_name = path.basename(file), | ||
file_path = path.relative(options.cwd, file).replace(/\\/g, '/'); | ||
file_path = path.relative(opts.cwd, file).replace(/\\/g, '/'); | ||
@@ -24,7 +40,30 @@ if (file_name.match(/^_/)) { | ||
if ('function' == typeof options) { | ||
callback = options; | ||
var options = []; | ||
options.push('compile'); | ||
options.push(file_path); | ||
// set compass setting | ||
if (opts.config_file) { | ||
options.push('-c', opts.config_file); | ||
} else { | ||
if (!opts.comments) { options.push('--no-line-comments'); } | ||
if (opts.relative) { options.push('--relative-assets'); } | ||
options.push('--output-style', opts.style); | ||
options.push('--css-dir', opts.css); | ||
options.push('--sass-dir', opts.sass); | ||
options.push('--images-dir', opts.img); | ||
} | ||
exec(compassExecutable + ' compile ' + file_path, {cwd: options.cwd}, callback); | ||
var compass = spawn(compassExecutable, options, {cwd: opts.project}); | ||
compass.stdout.setEncoding('utf8'); | ||
compass.stdout.on('data', function (data) { | ||
console.log(data); | ||
}); | ||
compass.stderr.setEncoding('utf8'); | ||
compass.stderr.on('data', function (data) { | ||
if (!data.match(/^\u001b\[\d+m$/)) { | ||
gutil.log(data); | ||
} | ||
}); | ||
}; |
{ | ||
"name": "gulp-compass", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Compile Compass files", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,6 +0,6 @@ | ||
# gulp compass | ||
# Gulp compass | ||
Compile Sass to CSS using Compass | ||
# Requirements | ||
## Requirements | ||
@@ -16,3 +16,3 @@ `gulp-compass` requires the compass ruby gem in order to compile compass. This can easily be installed via Terminal. | ||
# Installation | ||
## Installation | ||
@@ -23,4 +23,6 @@ ``` | ||
# Usage | ||
## Usage | ||
load your compass ``config.rb`` file. | ||
```javascript | ||
@@ -31,5 +33,62 @@ var compass = require('gulp-compass'); | ||
gulp.src('./src/*.scss') | ||
.pipe(compass()) | ||
.pipe(compass( | ||
config_file: './config.rb' | ||
)); | ||
}); | ||
``` | ||
set your compass settings. | ||
```javascript | ||
var compass = require('gulp-compass'); | ||
gulp.task('compass', function() { | ||
gulp.src('./src/*.scss') | ||
.pipe(compass( | ||
css: 'app/assets/css', | ||
sass: 'app/assets/sass', | ||
image: 'app/assets/images' | ||
)); | ||
}); | ||
``` | ||
## Configuration | ||
### Configuration Options | ||
#### style | ||
**default:** nested | ||
**description:** The output style for the compiled css. | ||
One of: nested, expanded, compact, or compressed. | ||
#### comments | ||
**default:** true | ||
**description:** Show line comments or not. | ||
#### relative | ||
**default:** true | ||
**description:** Are assets relative. | ||
#### css | ||
**default:** css | ||
**description:** The folder inside the project to output css into. | ||
#### sass | ||
**default:** sass | ||
**description:** The folder inside the project to find sass in. | ||
#### project | ||
**default:** your project base | ||
**description:** The location where all your assets are store. |
4651
68
91