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
1f9e90d2
Commit
1f9e90d2
authored
Apr 17, 2014
by
Johannes Ewald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Normalized option handling
parent
50e38666
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
55 deletions
+44
-55
sass.js
sass.js
+44
-55
No files found.
sass.js
View file @
1f9e90d2
...
@@ -31,80 +31,79 @@ var SASS_OUTPUT_STYLE = {
...
@@ -31,80 +31,79 @@ var SASS_OUTPUT_STYLE = {
var
SASS_SOURCE_COMMENTS
=
{
var
SASS_SOURCE_COMMENTS
=
{
none
:
0
,
none
:
0
,
// This is called default in libsass, but is a reserved keyword here
normal
:
1
,
normal
:
1
,
'default'
:
1
,
map
:
2
map
:
2
};
};
var
prepareOptions
=
function
(
options
)
{
var
noop
=
function
()
{};
var
paths
,
imagePath
,
style
,
comments
;
options
=
typeof
options
!==
'object'
?
{}
:
options
;
var
prepareOptions
=
function
(
options
)
{
var
sourceComments
=
options
.
source_comments
||
options
.
sourceComments
;
var
sourceComments
;
options
=
options
||
{};
sourceComments
=
options
.
source_comments
||
options
.
sourceComments
;
if
(
options
.
sourceMap
&&
!
sourceComments
)
{
if
(
options
.
sourceMap
&&
!
sourceComments
)
{
sourceComments
=
'map'
;
sourceComments
=
'map'
;
}
}
paths
=
options
.
include_paths
||
options
.
includePaths
||
[];
imagePath
=
options
.
image_path
||
options
.
imagePath
||
''
;
style
=
SASS_OUTPUT_STYLE
[
options
.
output_style
||
options
.
outputStyle
]
||
0
;
comments
=
SASS_SOURCE_COMMENTS
[
sourceComments
]
||
0
;
return
{
return
{
paths
:
paths
,
file
:
options
.
file
||
null
,
imagePath
:
imagePath
,
outFile
:
options
.
outFile
||
null
,
style
:
style
,
data
:
options
.
data
||
null
,
comments
:
comments
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
]
||
0
,
sourceMap
:
options
.
sourceMap
,
success
:
options
.
success
||
noop
,
error
:
options
.
error
||
noop
};
};
};
};
var
deprecatedRender
=
function
(
css
,
callback
,
options
)
{
var
deprecatedRender
=
function
(
css
,
callback
,
options
)
{
options
=
prepareOptions
(
options
);
options
=
prepareOptions
(
options
);
var
errCallback
=
function
(
err
)
{
// providing the deprecated single callback signature
callback
(
err
);
options
.
error
=
callback
;
};
options
.
success
=
function
(
css
)
{
var
oldCallback
=
function
(
css
)
{
callback
(
null
,
css
);
callback
(
null
,
css
);
};
};
return
binding
.
render
(
css
,
options
.
imagePath
,
o
ldCallback
,
errCallback
,
options
.
paths
.
join
(
path
.
delimiter
)
,
options
.
style
,
options
.
comments
);
return
binding
.
render
(
css
,
options
.
imagePath
,
o
ptions
.
success
,
options
.
error
,
options
.
paths
,
options
.
style
,
options
.
comments
);
};
};
var
deprecatedRenderSync
=
function
(
css
,
options
)
{
var
deprecatedRenderSync
=
function
(
css
,
options
)
{
options
=
prepareOptions
(
options
);
options
=
prepareOptions
(
options
);
return
binding
.
renderSync
(
css
,
options
.
imagePath
,
options
.
paths
.
join
(
path
.
delimiter
)
,
options
.
style
,
options
.
comments
);
return
binding
.
renderSync
(
css
,
options
.
imagePath
,
options
.
paths
,
options
.
style
,
options
.
comments
);
};
};
exports
.
render
=
function
(
options
)
{
exports
.
render
=
function
(
options
)
{
var
newOptions
;
if
(
typeof
arguments
[
0
]
===
'string'
)
{
if
(
typeof
arguments
[
0
]
===
'string'
)
{
return
deprecatedRender
.
apply
(
this
,
arguments
);
return
deprecatedRender
.
apply
(
this
,
arguments
);
}
}
newOptions
=
prepareOptions
(
options
);
options
=
prepareOptions
(
options
);
options
.
error
=
options
.
error
||
function
(){};
if
(
options
.
file
!==
undefined
&&
options
.
file
!==
null
)
{
if
(
options
.
file
)
{
return
binding
.
renderFile
(
options
.
file
,
newOptions
.
imagePath
,
options
.
success
,
options
.
error
,
newOptions
.
paths
.
join
(
path
.
delimiter
),
newOptions
.
style
,
newO
ptions
.
comments
,
options
.
sourceMap
);
return
binding
.
renderFile
(
options
.
file
,
options
.
imagePath
,
options
.
success
,
options
.
error
,
options
.
paths
,
options
.
style
,
o
ptions
.
comments
,
options
.
sourceMap
);
}
}
//Assume data is present if file is not. binding/libsass will tell the user otherwise!
//Assume data is present if file is not. binding/libsass will tell the user otherwise!
return
binding
.
render
(
options
.
data
,
newOptions
.
imagePath
,
options
.
success
,
options
.
error
,
newOptions
.
paths
.
join
(
path
.
delimiter
),
newO
ptions
.
style
);
return
binding
.
render
(
options
.
data
,
options
.
imagePath
,
options
.
success
,
options
.
error
,
options
.
paths
,
o
ptions
.
style
);
};
};
exports
.
renderSync
=
function
(
options
)
{
exports
.
renderSync
=
function
(
options
)
{
var
newOptions
;
if
(
typeof
arguments
[
0
]
===
'string'
)
{
if
(
typeof
arguments
[
0
]
===
'string'
)
{
return
deprecatedRenderSync
.
apply
(
this
,
arguments
);
return
deprecatedRenderSync
.
apply
(
this
,
arguments
);
}
}
newO
ptions
=
prepareOptions
(
options
);
o
ptions
=
prepareOptions
(
options
);
if
(
options
.
file
!==
undefined
&&
options
.
file
!==
null
)
{
if
(
options
.
file
)
{
return
binding
.
renderFileSync
(
options
.
file
,
newOptions
.
imagePath
,
newOptions
.
paths
.
join
(
path
.
delimiter
),
newOptions
.
style
,
newO
ptions
.
comments
);
return
binding
.
renderFileSync
(
options
.
file
,
options
.
imagePath
,
options
.
paths
,
options
.
style
,
o
ptions
.
comments
);
}
}
//Assume data is present if file is not. binding/libsass will tell the user otherwise!
//Assume data is present if file is not. binding/libsass will tell the user otherwise!
return
binding
.
renderSync
(
options
.
data
,
newOptions
.
imagePath
,
newOptions
.
paths
.
join
(
path
.
delimiter
),
newO
ptions
.
style
);
return
binding
.
renderSync
(
options
.
data
,
options
.
imagePath
,
options
.
paths
,
o
ptions
.
style
);
};
};
/**
/**
...
@@ -120,26 +119,26 @@ exports.renderSync = function(options) {
...
@@ -120,26 +119,26 @@ exports.renderSync = function(options) {
where the source map should be saved
where the source map should be saved
*/
*/
exports
.
renderFile
=
function
(
options
)
{
exports
.
renderFile
=
function
(
options
)
{
var
newOptions
=
{};
var
success
;
for
(
var
i
in
options
)
{
if
(
options
.
hasOwnProperty
(
i
))
{
options
=
prepareOptions
(
options
);
newOptions
[
i
]
=
options
[
i
];
success
=
options
.
success
;
}
}
if
(
options
.
sourceMap
===
true
)
{
if
(
options
.
sourceMap
===
true
)
{
newO
ptions
.
sourceMap
=
path
.
basename
(
options
.
outFile
)
+
'.map'
;
o
ptions
.
sourceMap
=
path
.
basename
(
options
.
outFile
)
+
'.map'
;
}
}
newO
ptions
.
success
=
function
(
css
,
sourceMap
)
{
o
ptions
.
success
=
function
(
css
,
sourceMap
)
{
fs
.
writeFile
(
options
.
outFile
,
css
,
function
(
err
)
{
fs
.
writeFile
(
options
.
outFile
,
css
,
function
(
err
)
{
var
dir
,
sourceMapFile
;
if
(
err
)
{
if
(
err
)
{
return
error
(
err
);
return
options
.
error
(
err
);
}
}
if
(
options
.
sourceMap
)
{
if
(
options
.
sourceMap
)
{
var
dir
=
path
.
dirname
(
options
.
outFile
);
dir
=
path
.
dirname
(
options
.
outFile
);
var
sourceMapFile
=
path
.
resolve
(
dir
,
newO
ptions
.
sourceMap
);
sourceMapFile
=
path
.
resolve
(
dir
,
o
ptions
.
sourceMap
);
fs
.
writeFile
(
sourceMapFile
,
sourceMap
,
function
(
err
)
{
fs
.
writeFile
(
sourceMapFile
,
sourceMap
,
function
(
err
)
{
if
(
err
)
{
if
(
err
)
{
return
error
(
err
);
return
options
.
error
(
err
);
}
}
success
(
options
.
outFile
,
sourceMapFile
);
success
(
options
.
outFile
,
sourceMapFile
);
});
});
...
@@ -149,17 +148,7 @@ exports.renderFile = function(options) {
...
@@ -149,17 +148,7 @@ exports.renderFile = function(options) {
}
}
});
});
};
};
function
error
(
err
)
{
exports
.
render
(
options
);
if
(
options
.
error
)
{
options
.
error
(
err
);
}
}
function
success
(
css
,
sourceMap
)
{
if
(
options
.
success
)
{
options
.
success
(
css
,
sourceMap
);
}
}
exports
.
render
(
newOptions
);
};
};
exports
.
middleware
=
require
(
'./lib/middleware'
);
exports
.
middleware
=
require
(
'./lib/middleware'
);
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