Commit 9b752b27 by Steven Luscher

Added the --image-path option to the cli interface.

parent 140b20c7
...@@ -21,6 +21,10 @@ var optimist = require('optimist') ...@@ -21,6 +21,10 @@ var optimist = require('optimist')
describe: 'Path to look for @import-ed files', describe: 'Path to look for @import-ed files',
'default': cwd 'default': cwd
}) })
.options('image-path', {
describe: 'Path to prepend when using the image-url(…) helper',
'default': ''
})
.options('watch', { .options('watch', {
describe: 'Watch a directory or file', describe: 'Watch a directory or file',
alias: 'w' alias: 'w'
...@@ -97,6 +101,9 @@ exports = module.exports = function(args) { ...@@ -97,6 +101,9 @@ exports = module.exports = function(args) {
options.includePaths = [options.includePaths]; options.includePaths = [options.includePaths];
} }
// include the image path.
options.imagePath = argv['image-path'];
// if it's an array, make it a string // if it's an array, make it a string
options.outputStyle = argv['output-style']; options.outputStyle = argv['output-style'];
if (Array.isArray(options.outputStyle)) { if (Array.isArray(options.outputStyle)) {
......
...@@ -7,6 +7,7 @@ function render(options, emitter) { ...@@ -7,6 +7,7 @@ function render(options, emitter) {
sass.render({ sass.render({
file: options.inFile, file: options.inFile,
includePaths: options.includePaths, includePaths: options.includePaths,
imagePath: options.imagePath,
outputStyle: options.outputStyle, outputStyle: options.outputStyle,
sourceComments: options.sourceComments, sourceComments: options.sourceComments,
sourceMap: options.sourceMap, sourceMap: options.sourceMap,
......
...@@ -24,6 +24,9 @@ var expectedSampleNoComments = '#navbar {\n\ ...@@ -24,6 +24,9 @@ var expectedSampleNoComments = '#navbar {\n\
#navbar li a {\n\ #navbar li a {\n\
font-weight: bold; }\n'; font-weight: bold; }\n';
var expectedSampleCustomImagePath = 'body {\n\
background-image: url("/path/to/images/image.png"); }\n';
describe('cli', function() { describe('cli', function() {
it('should print help when run with no arguments', function(done) { it('should print help when run with no arguments', function(done) {
exec('node ' + cliPath, function(err, stdout, stderr) { exec('node ' + cliPath, function(err, stdout, stderr) {
...@@ -90,6 +93,15 @@ describe('cli', function() { ...@@ -90,6 +93,15 @@ describe('cli', function() {
}); });
}); });
it('should compile with the --image-path option', function(done){
var emitter = cli(['--image-path', '/path/to/images', path.join(__dirname, 'image_path.scss')]);
emitter.on('error', done);
emitter.on('write', function(err, file, css){
assert.equal(css, expectedSampleCustomImagePath);
fs.unlink(file, done);
});
});
it('should write the output to the file specified with the --output option', function(done){ it('should write the output to the file specified with the --output option', function(done){
var resultPath = path.join(__dirname, '../output.css'); var resultPath = path.join(__dirname, '../output.css');
var emitter = cli(['--output', resultPath, path.join(__dirname, 'sample.scss')]); var emitter = cli(['--output', resultPath, path.join(__dirname, 'sample.scss')]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment