Commit 5f275e71 by Andrew Nesbitt

Merge pull request #485 from am11/master

Misc. Fixes
parents fe1699f6 c64d596b
......@@ -24,4 +24,5 @@ bin/*-v8-*
lib-coverage/
sass-coverage.js
sample.css
sample.map
# node-sass
# node-sass
![logo](https://rawgit.com/sass/node-sass/master/media/logo.svg)
......@@ -81,9 +81,10 @@ The API for using node-sass has changed, so that now there is only one variable
`precision` is a `Number` that will be used to determine how many digits after the decimal will be allowed. For instance, if you had a decimal number of `1.23456789` and a precision of `5`, the result will be `1.23457` in the final CSS.
#### sourceComments
`sourceComments` is a `String` to determine what debug information is included in the output file. Its value should be one of `'none', 'normal', 'map'`. The default is `'none'`.
The `map` option will create the source map file in your CSS destination.
[Important: `souceComments` is only supported when using the `file` option, and does nothing when using `data` flag.]
`sourceComments` is a `Boolean` flag to determine what debug information is included in the output file.
#### omitSourceMapUrl
`omitSourceMapUrl` is a `Boolean` flag to determine whether to include `sourceMappingURL` comment in the output file.
#### sourceMap
If your `sourceComments` option is set to `map`, `sourceMap` allows setting a new path context for the referenced Sass files.
......@@ -235,10 +236,11 @@ Output will be saved with the same name as input SASS file into the current work
**Options:**
--output-style CSS output style (nested|expanded|compact|compressed) [default: "nested"]
--source-comments Include debug info in output (none|normal|map) [default: "none"]
--include-path Path to look for @import-ed files [default: cwd]
--help, -h Print usage info
--output-style CSS output style (nested|expanded|compact|compressed) [default: "nested"]
--source-comments Include debug info in output [default: false]
--omit-source-map-url Omit source map URL comment from output [default: false]
--include-path Path to look for @import-ed files [default: cwd]
--help, -h Print usage info
## Post-install Build
......
......@@ -11,12 +11,12 @@ environment:
install:
- ps: Install-Product node $env:nodejs_version
- cmd: SET PATH=C:\python27;%PATH%
- cmd: git submodule update --init --recursive
- npm install --msvs_version=2013
- git submodule update --init --recursive
- ps: npm install --msvs_version=2013
test_script:
- node --version
- npm --version
- cmd: npm test
- ps: npm test
build: off
......@@ -25,7 +25,7 @@ function init(args) {
' -x, --omit-source-map-url Omit source map URL comment from output',
' -i, --indented-syntax Treat data from stdin as sass code (versus scss)',
' --output-style CSS output style (nested|expanded|compact|compressed)',
' --source-comments Include debug info in output (none|normal|map)',
' --source-comments Include debug info in output',
' --source-map Emit source map',
' --include-path Path to look for imported files',
' --image-path Path to prepend when using the `image-url()` helper',
......@@ -38,28 +38,28 @@ function init(args) {
'indented-syntax',
'omit-source-map-url',
'stdout',
'watch'
'watch',
'source-comments'
],
string: [
'image-path',
'include-path',
'output',
'output-style',
'precision',
'source-comments'
'precision'
],
alias: {
i: 'indented-syntax',
o: 'output',
w: 'watch',
x: 'omit-source-map-url'
x: 'omit-source-map-url',
c: 'source-comments'
},
default: {
'image-path': '',
'include-path': cwd,
'output-style': 'nested',
precision: 5,
'source-comments': 'none'
precision: 5
}
});
}
......
Subproject commit f660edea1f747950ad0ddedd07f794d377b70132
Subproject commit ca5f271883db61ccd1d1e1b84dd4830a2564896f
......@@ -31,13 +31,6 @@ var SASS_OUTPUT_STYLE = {
compressed: 3
};
var SASS_SOURCE_COMMENTS = {
none: false,
normal: true,
default: false,
map: true
};
var prepareOptions = function (options) {
var success;
var error;
......@@ -50,11 +43,7 @@ var prepareOptions = function (options) {
error = options.error;
stats = options.stats || {};
sourceComments = options.source_comments || options.sourceComments;
if (options.sourceMap && !sourceComments) {
sourceComments = 'map';
}
sourceComments = options.source_comments || options.sourceComments || false;
if (typeof options.outFile === 'string' && typeof options.file === 'string' && path.resolve(options.outFile) === path.normalize(options.outFile).replace(new RegExp(path.sep + '$'), '' )) {
options.outFile = path.resolve(path.dirname(options.file), options.outFile);
......@@ -62,10 +51,12 @@ var prepareOptions = function (options) {
sourceMap = options.sourceMap;
if ((typeof sourceMap !== 'string' || !sourceMap.trim()) && sourceComments === 'map') {
sourceMap = options.outFile !== null ? options.outFile + '.map' : '';
} else if (options.outFile && sourceMap) {
sourceMap = path.resolve(path.dirname(options.file), sourceMap);
if (sourceMap) {
if (typeof sourceMap !== 'string' || !sourceMap.trim()) {
sourceMap = options.outFile !== null ? options.outFile + '.map' : '';
} else if (options.outFile) {
sourceMap = path.resolve(path.dirname(options.file), sourceMap);
}
}
prepareStats(options, stats);
......@@ -81,7 +72,7 @@ var prepareOptions = function (options) {
paths: (options.include_paths || options.includePaths || []).join(path.delimiter),
imagePath: options.image_path || options.imagePath || '',
style: SASS_OUTPUT_STYLE[options.output_style || options.outputStyle] || 0,
comments: SASS_SOURCE_COMMENTS[sourceComments] || false,
comments: sourceComments,
omitSourceMapUrl: options.omitSourceMapUrl,
indentedSyntax: options.indentedSyntax,
stats: stats,
......
......@@ -25,6 +25,24 @@ var expectedSampleNoComments = '#navbar {\n\
#navbar li a {\n\
font-weight: bold; }\n';
var sampleFilenameFwdSlashes = sampleFilename.replace(/\\/g, '/');
var expectedSampleComments = '/* line 1, ' + sampleFilenameFwdSlashes + ' */\n\
#navbar {\n\
width: 80%;\n\
height: 23px; }\n\
\n\
/* line 5, ' + sampleFilenameFwdSlashes + ' */\n\
#navbar ul {\n\
list-style-type: none; }\n\
\n\
/* line 8, ' + sampleFilenameFwdSlashes + ' */\n\
#navbar li {\n\
float: left; }\n\
/* line 10, ' + sampleFilenameFwdSlashes + ' */\n\
#navbar li a {\n\
font-weight: bold; }\n';
var expectedSampleCustomImagePath = 'body {\n\
background-image: url("/path/to/images/image.png"); }\n';
......@@ -143,10 +161,10 @@ describe('cli', function() {
});
it('should compile with the --source-comments option', function(done) {
var emitter = cli(['--source-comments', 'none', sampleScssPath]);
var emitter = cli(['--source-comments', sampleScssPath]);
emitter.on('error', done);
emitter.on('write', function(err, file, css) {
assert.equal(css, expectedSampleNoComments);
assert.equal(css, expectedSampleComments);
fs.unlink(file, done);
});
});
......@@ -252,8 +270,8 @@ describe('cli', function() {
});
});
it('should compile a sourceMap if --source-comments="map", but the --source-map option is excluded', function(done) {
var emitter = cli([sampleScssPath, '--source-comments', 'map']);
it('should not compile a sourceMap if --source-map option is excluded', function(done) {
var emitter = cli([sampleScssPath, '--source-comments']);
emitter.on('error', done);
emitter.on('write-source-map', function(err, file) {
assert.equal(file, sampleCssMapOutputPath);
......
Subproject commit 97aed6fb4661be19f521a4a4ecc3ea6db941cd4c
Subproject commit f01abbf6d47ec62f3248ef0aa5bd5609e2223c8a
......@@ -23,7 +23,7 @@ describe('compile file with source comments', function() {
it('should compile with render and comment outputs', function(done) {
sass.render({
file: sampleFilename,
source_comments: 'normal',
source_comments: 'map',
success: function (css) {
done(assert.equal(css, expectedCommentsScssStr));
},
......
......@@ -318,7 +318,6 @@ describe('compile with stats', function() {
sass.renderSync({
file: sampleFilename,
stats: stats,
sourceComments: 'map',
sourceMap: true
});
......
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