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
19ea3a09
Commit
19ea3a09
authored
Jan 02, 2014
by
Dean Mao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revert my revert augh!
parent
4f5e8777
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
27 deletions
+52
-27
binding.cpp
binding.cpp
+0
-0
sass.js
sass.js
+21
-22
sass_context_wrapper.cpp
sass_context_wrapper.cpp
+18
-1
sass_context_wrapper.h
sass_context_wrapper.h
+13
-4
No files found.
binding.cpp
View file @
19ea3a09
This diff is collapsed.
Click to expand it.
sass.js
View file @
19ea3a09
var
binding
;
var
fs
=
require
(
'fs'
);
var
path
=
require
(
'path'
);
var
v8
=
'v8-'
+
/
[
0-9
]
+
\.[
0-9
]
+/
.
exec
(
process
.
versions
.
v8
)[
0
];
var
modPath
=
path
.
join
(
__dirname
,
'bin'
,
process
.
platform
+
'-'
+
process
.
arch
+
'-'
+
v8
,
'binding'
);
try
{
if
(
fs
.
realpathSync
(
__dirname
+
'/build'
))
{
// use the build version if it exists
binding
=
require
(
__dirname
+
'/build/Release/binding'
);
}
}
catch
(
e
)
{
// default to a precompiled binary if no build exists
var
platform_full
=
process
.
platform
+
'-'
+
process
.
arch
;
binding
=
require
(
__dirname
+
'/precompiled/'
+
platform_full
+
'/binding'
);
}
if
(
binding
===
null
)
{
throw
new
Error
(
'Cannot find appropriate binary library for node-sass'
);
try
{
fs
.
realpathSync
(
modPath
+
'.node'
);
binding
=
require
(
modPath
);
}
catch
(
ex
)
{
// No binary!
throw
new
Error
(
'`'
+
modPath
+
'.node` is missing. Try reinstalling `node-sass`?'
);
}
}
var
SASS_OUTPUT_STYLE
=
{
...
...
@@ -29,11 +34,11 @@ var SASS_SOURCE_COMMENTS = {
};
var
prepareOptions
=
function
(
options
)
{
var
paths
,
style
,
comments
;
options
=
typeof
options
!==
'object'
?
{}
:
options
;
paths
=
options
.
include_paths
||
options
.
includePaths
||
[];
style
=
SASS_OUTPUT_STYLE
[
options
.
output_style
||
options
.
outputStyle
]
||
0
;
comments
=
SASS_SOURCE_COMMENTS
[
options
.
source_comments
||
options
.
sourceComments
]
||
0
;
var
paths
,
style
;
var
options
=
typeof
options
!==
'object'
?
{}
:
options
;
var
paths
=
options
.
include_paths
||
options
.
includePaths
||
[];
var
style
=
SASS_OUTPUT_STYLE
[
options
.
output_style
||
options
.
outputStyle
]
||
0
;
var
comments
=
SASS_SOURCE_COMMENTS
[
options
.
source_comments
||
options
.
sourceComments
]
||
0
;
return
{
paths
:
paths
,
...
...
@@ -44,13 +49,7 @@ var prepareOptions = function(options) {
var
deprecatedRender
=
function
(
css
,
callback
,
options
)
{
options
=
prepareOptions
(
options
);
var
errCallback
=
function
(
err
)
{
callback
(
err
);
};
var
oldCallback
=
function
(
css
,
err
)
{
callback
(
null
,
css
);
};
return
binding
.
render
(
css
,
oldCallback
,
errCallback
,
options
.
paths
.
join
(
':'
),
options
.
style
,
options
.
comments
);
return
binding
.
oldRender
(
css
,
callback
,
options
.
paths
.
join
(
':'
),
options
.
style
,
options
.
comments
);
};
var
deprecatedRenderSync
=
function
(
css
,
options
)
{
...
...
@@ -69,11 +68,11 @@ exports.render = function(options) {
options
.
error
=
options
.
error
||
function
(){};
if
(
options
.
file
!==
undefined
&&
options
.
file
!==
null
)
{
return
binding
.
renderFile
(
options
.
file
,
options
.
success
,
options
.
error
,
newOptions
.
paths
.
join
(
':'
),
newOptions
.
style
,
newOptions
.
comments
);
return
binding
.
renderFile
(
options
.
file
,
options
.
success
,
options
.
error
,
newOptions
.
paths
.
join
(
path
.
delimiter
),
newOptions
.
style
,
newOptions
.
comments
);
}
//Assume data is present if file is not. binding/libsass will tell the user otherwise!
return
binding
.
render
(
options
.
data
,
options
.
success
,
options
.
error
,
newOptions
.
paths
.
join
(
":"
),
newOptions
.
style
);
return
binding
.
render
(
options
.
data
,
options
.
success
,
options
.
error
,
newOptions
.
paths
.
join
(
path
.
delimiter
),
newOptions
.
style
);
};
exports
.
renderSync
=
function
(
options
)
{
...
...
@@ -86,11 +85,11 @@ exports.renderSync = function(options) {
newOptions
=
prepareOptions
(
options
);
if
(
options
.
file
!==
undefined
&&
options
.
file
!==
null
)
{
return
binding
.
renderFileSync
(
options
.
file
,
newOptions
.
paths
.
join
(
':'
),
newOptions
.
style
,
newOptions
.
comments
);
return
binding
.
renderFileSync
(
options
.
file
,
newOptions
.
paths
.
join
(
path
.
delimiter
),
newOptions
.
style
,
newOptions
.
comments
);
}
//Assume data is present if file is not. binding/libsass will tell the user otherwise!
return
binding
.
renderSync
(
options
.
data
,
newOptions
.
paths
.
join
(
":"
),
newOptions
.
style
);
return
binding
.
renderSync
(
options
.
data
,
newOptions
.
paths
.
join
(
path
.
delimiter
),
newOptions
.
style
);
};
exports
.
middleware
=
require
(
'./lib/middleware'
);
sass_context_wrapper.cpp
View file @
19ea3a09
...
...
@@ -12,7 +12,24 @@ extern "C" {
void
sass_free_context_wrapper
(
sass_context_wrapper
*
ctx_w
)
{
if
(
ctx_w
->
ctx
)
sass_free_context
(
ctx_w
->
ctx
);
if
(
ctx_w
->
fctx
)
sass_free_file_context
(
ctx_w
->
fctx
);
delete
ctx_w
->
callback
;
delete
ctx_w
->
errorCallback
;
free
(
ctx_w
);
}
sass_file_context_wrapper
*
sass_new_file_context_wrapper
()
{
return
(
sass_file_context_wrapper
*
)
calloc
(
1
,
sizeof
(
sass_file_context_wrapper
));
}
void
sass_free_file_context_wrapper
(
sass_file_context_wrapper
*
ctx_w
)
{
if
(
ctx_w
->
ctx
)
sass_free_file_context
(
ctx_w
->
ctx
);
delete
ctx_w
->
callback
;
delete
ctx_w
->
errorCallback
;
free
(
ctx_w
);
}
...
...
sass_context_wrapper.h
View file @
19ea3a09
#include "libsass/sass_interface.h"
#include <n
ode
.h>
#include <n
an
.h>
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -7,15 +7,24 @@ extern "C" {
struct
sass_context_wrapper
{
sass_context
*
ctx
;
sass_file_context
*
fctx
;
uv_work_t
request
;
v8
::
Persistent
<
v8
::
Function
>
callback
;
v8
::
Persistent
<
v8
::
Function
>
errorCallback
;
NanCallback
*
callback
;
NanCallback
*
errorCallback
;
};
struct
sass_context_wrapper
*
sass_new_context_wrapper
(
void
);
void
sass_free_context_wrapper
(
struct
sass_context_wrapper
*
ctx
);
struct
sass_file_context_wrapper
{
sass_file_context
*
ctx
;
uv_work_t
request
;
NanCallback
*
callback
;
NanCallback
*
errorCallback
;
};
struct
sass_file_context_wrapper
*
sass_new_file_context_wrapper
(
void
);
void
sass_free_file_context_wrapper
(
struct
sass_file_context_wrapper
*
ctx
);
#ifdef __cplusplus
}
#endif
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