Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sass
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
楚学文
node-sass
Commits
d293b634
Commit
d293b634
authored
Oct 28, 2014
by
Adeel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sourceComment: Changes behavior (BREAKING change).
parent
15c0912f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
30 deletions
+38
-30
cli.js
lib/cli.js
+7
-7
sass.js
sass.js
+8
-17
cli.js
test/cli.js
+22
-4
source_comments_spec.js
test/source_comments_spec.js
+1
-1
test.js
test/test.js
+0
-1
No files found.
lib/cli.js
View file @
d293b634
...
@@ -25,7 +25,7 @@ function init(args) {
...
@@ -25,7 +25,7 @@ function init(args) {
' -x, --omit-source-map-url Omit source map URL comment from output'
,
' -x, --omit-source-map-url Omit source map URL comment from output'
,
' -i, --indented-syntax Treat data from stdin as sass code (versus scss)'
,
' -i, --indented-syntax Treat data from stdin as sass code (versus scss)'
,
' --output-style CSS output style (nested|expanded|compact|compressed)'
,
' --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'
,
' --source-map Emit source map'
,
' --include-path Path to look for imported files'
,
' --include-path Path to look for imported files'
,
' --image-path Path to prepend when using the `image-url()` helper'
,
' --image-path Path to prepend when using the `image-url()` helper'
,
...
@@ -38,28 +38,28 @@ function init(args) {
...
@@ -38,28 +38,28 @@ function init(args) {
'indented-syntax'
,
'indented-syntax'
,
'omit-source-map-url'
,
'omit-source-map-url'
,
'stdout'
,
'stdout'
,
'watch'
'watch'
,
'source-comments'
],
],
string
:
[
string
:
[
'image-path'
,
'image-path'
,
'include-path'
,
'include-path'
,
'output'
,
'output'
,
'output-style'
,
'output-style'
,
'precision'
,
'precision'
'source-comments'
],
],
alias
:
{
alias
:
{
i
:
'indented-syntax'
,
i
:
'indented-syntax'
,
o
:
'output'
,
o
:
'output'
,
w
:
'watch'
,
w
:
'watch'
,
x
:
'omit-source-map-url'
x
:
'omit-source-map-url'
,
c
:
'source-comments'
},
},
default
:
{
default
:
{
'image-path'
:
''
,
'image-path'
:
''
,
'include-path'
:
cwd
,
'include-path'
:
cwd
,
'output-style'
:
'nested'
,
'output-style'
:
'nested'
,
precision
:
5
,
precision
:
5
'source-comments'
:
'none'
}
}
});
});
}
}
...
...
sass.js
View file @
d293b634
...
@@ -31,13 +31,6 @@ var SASS_OUTPUT_STYLE = {
...
@@ -31,13 +31,6 @@ var SASS_OUTPUT_STYLE = {
compressed
:
3
compressed
:
3
};
};
var
SASS_SOURCE_COMMENTS
=
{
none
:
false
,
normal
:
true
,
default
:
false
,
map
:
true
};
var
prepareOptions
=
function
(
options
)
{
var
prepareOptions
=
function
(
options
)
{
var
success
;
var
success
;
var
error
;
var
error
;
...
@@ -50,11 +43,7 @@ var prepareOptions = function (options) {
...
@@ -50,11 +43,7 @@ var prepareOptions = function (options) {
error
=
options
.
error
;
error
=
options
.
error
;
stats
=
options
.
stats
||
{};
stats
=
options
.
stats
||
{};
sourceComments
=
options
.
source_comments
||
options
.
sourceComments
;
sourceComments
=
options
.
source_comments
||
options
.
sourceComments
||
false
;
if
(
options
.
sourceMap
&&
!
sourceComments
)
{
sourceComments
=
'map'
;
}
if
(
typeof
options
.
outFile
===
'string'
&&
typeof
options
.
file
===
'string'
&&
path
.
resolve
(
options
.
outFile
)
===
path
.
normalize
(
options
.
outFile
).
replace
(
new
RegExp
(
path
.
sep
+
'$'
),
''
))
{
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
);
options
.
outFile
=
path
.
resolve
(
path
.
dirname
(
options
.
file
),
options
.
outFile
);
...
@@ -62,10 +51,12 @@ var prepareOptions = function (options) {
...
@@ -62,10 +51,12 @@ var prepareOptions = function (options) {
sourceMap
=
options
.
sourceMap
;
sourceMap
=
options
.
sourceMap
;
if
((
typeof
sourceMap
!==
'string'
||
!
sourceMap
.
trim
())
&&
sourceComments
===
'map'
)
{
if
(
sourceMap
)
{
sourceMap
=
options
.
outFile
!==
null
?
options
.
outFile
+
'.map'
:
''
;
if
(
typeof
sourceMap
!==
'string'
||
!
sourceMap
.
trim
())
{
}
else
if
(
options
.
outFile
&&
sourceMap
)
{
sourceMap
=
options
.
outFile
!==
null
?
options
.
outFile
+
'.map'
:
''
;
sourceMap
=
path
.
resolve
(
path
.
dirname
(
options
.
file
),
sourceMap
);
}
else
if
(
options
.
outFile
)
{
sourceMap
=
path
.
resolve
(
path
.
dirname
(
options
.
file
),
sourceMap
);
}
}
}
prepareStats
(
options
,
stats
);
prepareStats
(
options
,
stats
);
...
@@ -81,7 +72,7 @@ var prepareOptions = function (options) {
...
@@ -81,7 +72,7 @@ var prepareOptions = function (options) {
paths
:
(
options
.
include_paths
||
options
.
includePaths
||
[]).
join
(
path
.
delimiter
),
paths
:
(
options
.
include_paths
||
options
.
includePaths
||
[]).
join
(
path
.
delimiter
),
imagePath
:
options
.
image_path
||
options
.
imagePath
||
''
,
imagePath
:
options
.
image_path
||
options
.
imagePath
||
''
,
style
:
SASS_OUTPUT_STYLE
[
options
.
output_style
||
options
.
outputStyle
]
||
0
,
style
:
SASS_OUTPUT_STYLE
[
options
.
output_style
||
options
.
outputStyle
]
||
0
,
comments
:
SASS_SOURCE_COMMENTS
[
sourceComments
]
||
false
,
comments
:
sourceComments
,
omitSourceMapUrl
:
options
.
omitSourceMapUrl
,
omitSourceMapUrl
:
options
.
omitSourceMapUrl
,
indentedSyntax
:
options
.
indentedSyntax
,
indentedSyntax
:
options
.
indentedSyntax
,
stats
:
stats
,
stats
:
stats
,
...
...
test/cli.js
View file @
d293b634
...
@@ -25,6 +25,24 @@ var expectedSampleNoComments = '#navbar {\n\
...
@@ -25,6 +25,24 @@ var expectedSampleNoComments = '#navbar {\n\
#navbar li a {
\
n
\
#navbar li a {
\
n
\
font-weight: bold; }
\
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
\
var
expectedSampleCustomImagePath
=
'body {
\
n
\
background-image: url("/path/to/images/image.png"); }
\
n'
;
background-image: url("/path/to/images/image.png"); }
\
n'
;
...
@@ -143,10 +161,10 @@ describe('cli', function() {
...
@@ -143,10 +161,10 @@ describe('cli', function() {
});
});
it
(
'should compile with the --source-comments option'
,
function
(
done
)
{
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
(
'error'
,
done
);
emitter
.
on
(
'write'
,
function
(
err
,
file
,
css
)
{
emitter
.
on
(
'write'
,
function
(
err
,
file
,
css
)
{
assert
.
equal
(
css
,
expectedSample
No
Comments
);
assert
.
equal
(
css
,
expectedSampleComments
);
fs
.
unlink
(
file
,
done
);
fs
.
unlink
(
file
,
done
);
});
});
});
});
...
@@ -252,8 +270,8 @@ describe('cli', function() {
...
@@ -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
)
{
it
(
'should
not compile a sourceMap if
--source-map option is excluded'
,
function
(
done
)
{
var
emitter
=
cli
([
sampleScssPath
,
'--source-comments'
,
'map'
]);
var
emitter
=
cli
([
sampleScssPath
,
'--source-comments'
]);
emitter
.
on
(
'error'
,
done
);
emitter
.
on
(
'error'
,
done
);
emitter
.
on
(
'write-source-map'
,
function
(
err
,
file
)
{
emitter
.
on
(
'write-source-map'
,
function
(
err
,
file
)
{
assert
.
equal
(
file
,
sampleCssMapOutputPath
);
assert
.
equal
(
file
,
sampleCssMapOutputPath
);
...
...
test/source_comments_spec.js
View file @
d293b634
...
@@ -23,7 +23,7 @@ describe('compile file with source comments', function() {
...
@@ -23,7 +23,7 @@ describe('compile file with source comments', function() {
it
(
'should compile with render and comment outputs'
,
function
(
done
)
{
it
(
'should compile with render and comment outputs'
,
function
(
done
)
{
sass
.
render
({
sass
.
render
({
file
:
sampleFilename
,
file
:
sampleFilename
,
source_comments
:
'
normal
'
,
source_comments
:
'
map
'
,
success
:
function
(
css
)
{
success
:
function
(
css
)
{
done
(
assert
.
equal
(
css
,
expectedCommentsScssStr
));
done
(
assert
.
equal
(
css
,
expectedCommentsScssStr
));
},
},
...
...
test/test.js
View file @
d293b634
...
@@ -318,7 +318,6 @@ describe('compile with stats', function() {
...
@@ -318,7 +318,6 @@ describe('compile with stats', function() {
sass
.
renderSync
({
sass
.
renderSync
({
file
:
sampleFilename
,
file
:
sampleFilename
,
stats
:
stats
,
stats
:
stats
,
sourceComments
:
'map'
,
sourceMap
:
true
sourceMap
:
true
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment