Commit b2d2b9a6 by Adeel Mujahid

Merge pull request #704 from am11/master

API: Retires non-standard image-path option.
parents 9cc9b315 00454583
......@@ -109,9 +109,6 @@ The options passed in to `render` and `renderSync` are available as `this.option
#### includePaths
`includePaths` is an `Array` of path `String`s to look for any `@import`ed files. It is recommended that you use this option if you are using the `data` option and have **any** `@import` directives, as otherwise [libsass] may not find your depended-on files.
#### imagePath
`imagePath` is a `String` that represents the public image path. When using the `image-url()` function in a stylesheet, this path will be prepended to the path you supply. eg. Given an `imagePath` of `/path/to/images`, `background-image: image-url('image.png')` will compile to `background-image: url("/path/to/images/image.png")`
#### indentedSyntax
`indentedSyntax` is a `Boolean` flag to determine if [Sass Indented Syntax](http://sass-lang.com/documentation/file.INDENTED_SYNTAX.html) should be used to parse provided string or a file.
......@@ -338,7 +335,6 @@ Output will be saved with the same name as input SASS file into the current work
--source-map-embed Embed sourceMappingUrl as data URI
--source-map-contents Embed include contents in map
--include-path Path to look for imported files
--image-path Path to prepend when using the `image-url()` helper
--precision The amount of precision allowed in decimal numbers
--importer Path to custom importer
--help Print usage info
......
......@@ -36,7 +36,6 @@ var cli = meow({
' --source-map-embed Embed sourceMappingUrl as data URI',
' --source-map-contents Embed include contents in map',
' --include-path Path to look for imported files',
' --image-path Path to prepend when using the `image-url()` helper',
' --precision The amount of precision allowed in decimal numbers',
' --importer Path to custom importer',
' --help Print usage info'
......@@ -51,7 +50,6 @@ var cli = meow({
'source-comments'
],
string: [
'image-path',
'include-path',
'output',
'output-style',
......@@ -66,7 +64,6 @@ var cli = meow({
r: 'recursive'
},
default: {
'image-path': '',
'include-path': process.cwd(),
'output-style': 'nested',
precision: 5
......
......@@ -87,7 +87,7 @@ function endStats(stats) {
*/
function getStyle(options) {
var style = options.output_style || options.outputStyle;
var style = options.outputStyle;
var styles = {
nested: 0,
expanded: 1,
......@@ -127,14 +127,14 @@ function getSourceMap(options) {
* @param {Object} options
* @api private
*/
function getOptions(options, cb) {
options = options || {};
options.comments = options.source_comments || options.sourceComments || false;
options.comments = options.sourceComments || false;
options.data = options.data || null;
options.file = options.file || null;
options.imagePath = options.image_path || options.imagePath || '';
options.outFile = getOutFile(options);
options.paths = (options.include_paths || options.includePaths || []).join(path.delimiter);
options.paths = (options.includePaths || []).join(path.delimiter);
options.precision = parseInt(options.precision) || 5;
options.sourceMap = getSourceMap(options);
options.style = getStyle(options) || 0;
......@@ -142,10 +142,6 @@ function getOptions(options, cb) {
// context object represents node-sass environment
options.context = { options: options };
if (options.imagePath && typeof options.imagePath !== 'string') {
throw new Error('`imagePath` needs to be a string');
}
var error = options.error;
var success = options.success;
......@@ -177,7 +173,6 @@ function getOptions(options, cb) {
}
};
delete options.image_path;
delete options.include_paths;
delete options.includePaths;
delete options.source_comments;
......
......@@ -14,7 +14,6 @@ var fs = require('fs'),
module.exports = function(options, emitter) {
var renderOptions = {
imagePath: options.imagePath,
includePaths: options.includePath,
omitSourceMapUrl: options.omitSourceMapUrl,
indentedSyntax: options.indentedSyntax,
......
......@@ -151,7 +151,6 @@ void extract_options(Local<Object> options, void* cptr, sass_context_wrapper* ct
}
sass_option_set_output_path(sass_options, create_string(options->Get(NanNew("outFile"))));
sass_option_set_image_path(sass_options, create_string(options->Get(NanNew("imagePath"))));
sass_option_set_output_style(sass_options, (Sass_Output_Style)options->Get(NanNew("style"))->Int32Value());
sass_option_set_is_indented_syntax_src(sass_options, options->Get(NanNew("indentedSyntax"))->BooleanValue());
sass_option_set_source_comments(sass_options, options->Get(NanNew("comments"))->BooleanValue());
......
......@@ -114,31 +114,25 @@ describe('api', function() {
});
});
it('should compile with image path', function(done) {
var src = read(fixture('image-path/index.scss'), 'utf8');
var expected = read(fixture('image-path/expected.css'), 'utf8').trim();
sass.render({
data: src,
imagePath: '/path/to/images',
success: function(result) {
assert.equal(result.css.trim(), expected.replace(/\r\n/g, '\n'));
done();
}
});
});
it('should throw error with non-string image path', function(done) {
var src = read(fixture('image-path/index.scss'), 'utf8');
it('should throw error when libsass binary is missing.', function(done) {
var originalBin = path.join('vendor', process.sassBinaryName, 'binding.node'),
renamedBin = [originalBin, '_moved'].join('');
assert.throws(function() {
sass.render({
data: src,
imagePath: ['/path/to/images']
});
});
// un-require node-sass
var resolved = require.resolve('../lib');
delete require.cache[resolved];
fs.renameSync(originalBin, renamedBin);
// try to re-require it
require('../lib');
}, function(err) {
if ((err instanceof Error) && /`libsass` bindings not found. Try reinstalling `node-sass`?/.test(err)) {
fs.renameSync(renamedBin, originalBin);
done();
return true;
}
});
});
it('should render with --precision option', function(done) {
......
......@@ -63,20 +63,6 @@ describe('cli', function() {
src.pipe(bin.stdin);
});
it('should compile with the --image-path option', function(done) {
var src = fs.createReadStream(fixture('image-path/index.scss'));
var expected = read(fixture('image-path/expected.css'), 'utf8').trim();
var bin = spawn(cli, ['--image-path', '/path/to/images']);
bin.stdout.setEncoding('utf8');
bin.stdout.once('data', function(data) {
assert.equal(data.trim(), expected.replace(/\r\n/g, '\n'));
done();
});
src.pipe(bin.stdin);
});
});
describe('node-sass in.scss', function() {
......
body {
background-image: url("/path/to/images/image.png"); }
body {
background-image: image-url('image.png');
}
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