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
ce2df81d
Commit
ce2df81d
authored
Jan 02, 2014
by
Nick Schonning
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #203 from nschonni/revert-breaking-build
Revert "merge in sourceMap support"
parents
a5007aea
17db21c9
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
214 additions
and
175 deletions
+214
-175
binding.cpp
binding.cpp
+167
-82
cli.js
lib/cli.js
+0
-13
render.js
lib/render.js
+1
-20
sass.js
sass.js
+21
-22
sass_context_wrapper.cpp
sass_context_wrapper.cpp
+15
-1
sass_context_wrapper.h
sass_context_wrapper.h
+10
-1
cli.js
test/cli.js
+0
-36
No files found.
binding.cpp
View file @
ce2df81d
...
@@ -11,114 +11,96 @@ using namespace std;
...
@@ -11,114 +11,96 @@ using namespace std;
void
WorkOnContext
(
uv_work_t
*
req
)
{
void
WorkOnContext
(
uv_work_t
*
req
)
{
sass_context_wrapper
*
ctx_w
=
static_cast
<
sass_context_wrapper
*>
(
req
->
data
);
sass_context_wrapper
*
ctx_w
=
static_cast
<
sass_context_wrapper
*>
(
req
->
data
);
if
(
ctx_w
->
ctx
)
{
sass_context
*
ctx
=
static_cast
<
sass_context
*>
(
ctx_w
->
ctx
);
sass_context
*
ctx
=
static_cast
<
sass_context
*>
(
ctx_w
->
ctx
);
sass_compile
(
ctx
);
sass_compile
(
ctx
);
}
else
if
(
ctx_w
->
fctx
)
{
sass_file_context
*
ctx
=
static_cast
<
sass_file_context
*>
(
ctx_w
->
fctx
);
sass_compile_file
(
ctx
);
}
}
}
void
extractOptions
(
_NAN_METHOD_ARGS
,
void
*
cptr
,
sass_context_wrapper
*
ctx_w
,
bool
isFile
)
{
void
MakeOldCallback
(
uv_work_t
*
req
)
{
char
*
source
;
NanScope
();
char
*
pathOrData
;
TryCatch
try_catch
;
int
output_style
;
sass_context_wrapper
*
ctx_w
=
static_cast
<
sass_context_wrapper
*>
(
req
->
data
);
int
source_comments
;
sass_context
*
ctx
=
static_cast
<
sass_context
*>
(
ctx_w
->
ctx
);
String
::
AsciiValue
astr
(
args
[
0
]);
if
(
ctx_w
)
{
if
(
ctx
->
error_status
==
0
)
{
// async (callback) style
// if no error, do callback(null, result)
Local
<
Function
>
callback
=
Local
<
Function
>::
Cast
(
args
[
1
]);
const
unsigned
argc
=
2
;
Local
<
Function
>
errorCallback
=
Local
<
Function
>::
Cast
(
args
[
2
]);
Local
<
Value
>
argv
[
argc
]
=
{
if
(
isFile
)
{
NanNewLocal
(
Null
()),
ctx_w
->
fctx
=
(
sass_file_context
*
)
cptr
;
NanNewLocal
(
String
::
New
(
ctx
->
output_string
))
};
ctx_w
->
callback
->
Call
(
argc
,
argv
);
}
else
{
}
else
{
ctx_w
->
ctx
=
(
sass_context
*
)
cptr
;
// if error, do callback(error)
const
unsigned
argc
=
1
;
Local
<
Value
>
argv
[
argc
]
=
{
NanNewLocal
(
String
::
New
(
ctx
->
error_message
))
};
ctx_w
->
callback
->
Call
(
argc
,
argv
);
}
}
ctx_w
->
request
.
data
=
ctx_w
;
if
(
try_catch
.
HasCaught
())
{
ctx_w
->
callback
=
new
NanCallback
(
callback
);
node
::
FatalException
(
try_catch
);
ctx_w
->
errorCallback
=
new
NanCallback
(
errorCallback
);
output_style
=
args
[
4
]
->
Int32Value
();
source_comments
=
args
[
5
]
->
Int32Value
();
String
::
AsciiValue
bstr
(
args
[
3
]);
pathOrData
=
new
char
[
strlen
(
*
bstr
)
+
1
];
strcpy
(
pathOrData
,
*
bstr
);
}
else
{
// synchronous style
output_style
=
args
[
2
]
->
Int32Value
();
source_comments
=
args
[
3
]
->
Int32Value
();
String
::
AsciiValue
bstr
(
args
[
1
]);
pathOrData
=
new
char
[
strlen
(
*
bstr
)
+
1
];
strcpy
(
pathOrData
,
*
bstr
);
}
}
delete
ctx
->
source_string
;
sass_free_context_wrapper
(
ctx_w
);
}
NAN_METHOD
(
OldRender
)
{
NanScope
();
sass_context
*
ctx
=
sass_new_context
();
sass_context_wrapper
*
ctx_w
=
sass_new_context_wrapper
();
char
*
source
;
String
::
AsciiValue
astr
(
args
[
0
]);
Local
<
Function
>
callback
=
Local
<
Function
>::
Cast
(
args
[
1
]);
String
::
AsciiValue
bstr
(
args
[
2
]);
if
(
isFile
)
{
sass_file_context
*
ctx
=
(
sass_file_context
*
)
cptr
;
char
*
filename
=
new
char
[
strlen
(
*
astr
)
+
1
];
strcpy
(
filename
,
*
astr
);
ctx
->
input_path
=
filename
;
ctx
->
options
.
image_path
=
new
char
[
0
];
ctx
->
options
.
output_style
=
output_style
;
ctx
->
options
.
source_comments
=
source_comments
;
ctx
->
options
.
include_paths
=
pathOrData
;
if
(
source_comments
==
SASS_SOURCE_COMMENTS_MAP
)
{
String
::
AsciiValue
cstr
(
args
[
6
]);
ctx
->
source_map_file
=
new
char
[
strlen
(
*
cstr
)
+
1
];
strcpy
(
ctx
->
source_map_file
,
*
cstr
);
}
}
else
{
sass_context
*
ctx
=
(
sass_context
*
)
cptr
;
source
=
new
char
[
strlen
(
*
astr
)
+
1
];
source
=
new
char
[
strlen
(
*
astr
)
+
1
];
strcpy
(
source
,
*
astr
);
strcpy
(
source
,
*
astr
);
ctx
->
source_string
=
source
;
ctx
->
source_string
=
source
;
ctx
->
options
.
include_paths
=
new
char
[
strlen
(
*
bstr
)
+
1
];
ctx
->
options
.
image_path
=
new
char
[
0
];
ctx
->
options
.
image_path
=
new
char
[
0
];
ctx
->
options
.
output_style
=
output_style
;
ctx
->
options
.
include_paths
=
*
bstr
;
ctx
->
options
.
source_comments
=
source_comments
;
// ctx->options.output_style = SASS_STYLE_NESTED;
ctx
->
options
.
include_paths
=
pathOrData
;
ctx
->
options
.
output_style
=
args
[
3
]
->
Int32Value
();
}
ctx
->
options
.
source_comments
=
args
[
4
]
->
Int32Value
();
ctx_w
->
ctx
=
ctx
;
ctx_w
->
callback
=
new
NanCallback
(
callback
);
ctx_w
->
request
.
data
=
ctx_w
;
int
status
=
uv_queue_work
(
uv_default_loop
(),
&
ctx_w
->
request
,
WorkOnContext
,
(
uv_after_work_cb
)
MakeOldCallback
);
assert
(
status
==
0
);
NanReturnUndefined
();
}
}
void
MakeCallback
(
uv_work_t
*
req
)
{
void
MakeCallback
(
uv_work_t
*
req
)
{
NanScope
();
NanScope
();
TryCatch
try_catch
;
TryCatch
try_catch
;
sass_context_wrapper
*
ctx_w
=
static_cast
<
sass_context_wrapper
*>
(
req
->
data
);
sass_context_wrapper
*
ctx_w
=
static_cast
<
sass_context_wrapper
*>
(
req
->
data
);
Handle
<
Value
>
val
,
err
;
sass_context
*
ctx
=
static_cast
<
sass_context
*>
(
ctx_w
->
ctx
);
int
error_status
=
ctx_w
->
ctx
?
ctx_w
->
ctx
->
error_status
:
ctx_w
->
fctx
->
error_status
;
if
(
error_status
==
0
)
{
if
(
ctx
->
error_status
==
0
)
{
// if no error, do callback(null, result)
// if no error, do callback(null, result)
const
unsigned
argc
=
2
;
const
unsigned
argc
=
1
;
Handle
<
Value
>
source_map
;
if
(
ctx_w
->
fctx
&&
ctx_w
->
fctx
->
options
.
source_comments
==
SASS_SOURCE_COMMENTS_MAP
)
{
source_map
=
String
::
New
(
ctx_w
->
fctx
->
source_map_string
);
}
else
{
source_map
=
Null
();
}
val
=
ctx_w
->
ctx
?
NanNewLocal
(
String
::
New
(
ctx_w
->
ctx
->
output_string
))
:
NanNewLocal
(
String
::
New
(
ctx_w
->
fctx
->
output_string
));
Local
<
Value
>
argv
[
argc
]
=
{
Local
<
Value
>
argv
[
argc
]
=
{
NanNewLocal
(
val
),
NanNewLocal
(
String
::
New
(
ctx
->
output_string
))
NanNewLocal
(
source_map
),
};
};
ctx_w
->
callback
->
Call
(
argc
,
argv
);
ctx_w
->
callback
->
Call
(
argc
,
argv
);
}
else
{
}
else
{
// if error, do callback(error)
// if error, do callback(error)
const
unsigned
argc
=
1
;
const
unsigned
argc
=
1
;
err
=
ctx_w
->
ctx
?
NanNewLocal
(
String
::
New
(
ctx_w
->
ctx
->
error_message
))
:
NanNewLocal
(
String
::
New
(
ctx_w
->
fctx
->
error_message
));
Local
<
Value
>
argv
[
argc
]
=
{
Local
<
Value
>
argv
[
argc
]
=
{
NanNewLocal
(
err
)
NanNewLocal
(
String
::
New
(
ctx
->
error_message
)
)
};
};
ctx_w
->
errorCallback
->
Call
(
argc
,
argv
);
ctx_w
->
errorCallback
->
Call
(
argc
,
argv
);
}
}
if
(
try_catch
.
HasCaught
())
{
if
(
try_catch
.
HasCaught
())
{
node
::
FatalException
(
try_catch
);
node
::
FatalException
(
try_catch
);
}
}
if
(
ctx_w
->
ctx
)
{
delete
ctx
->
source_string
;
delete
ctx_w
->
ctx
->
source_string
;
}
else
{
delete
ctx_w
->
fctx
->
input_path
;
}
sass_free_context_wrapper
(
ctx_w
);
sass_free_context_wrapper
(
ctx_w
);
}
}
...
@@ -126,8 +108,25 @@ NAN_METHOD(Render) {
...
@@ -126,8 +108,25 @@ NAN_METHOD(Render) {
NanScope
();
NanScope
();
sass_context
*
ctx
=
sass_new_context
();
sass_context
*
ctx
=
sass_new_context
();
sass_context_wrapper
*
ctx_w
=
sass_new_context_wrapper
();
sass_context_wrapper
*
ctx_w
=
sass_new_context_wrapper
();
char
*
source
;
String
::
AsciiValue
astr
(
args
[
0
]);
Local
<
Function
>
callback
=
Local
<
Function
>::
Cast
(
args
[
1
]);
Local
<
Function
>
errorCallback
=
Local
<
Function
>::
Cast
(
args
[
2
]);
String
::
AsciiValue
bstr
(
args
[
3
]);
source
=
new
char
[
strlen
(
*
astr
)
+
1
];
strcpy
(
source
,
*
astr
);
ctx
->
source_string
=
source
;
ctx
->
options
.
include_paths
=
new
char
[
strlen
(
*
bstr
)
+
1
];
ctx
->
options
.
include_paths
=
*
bstr
;
// ctx->options.output_style = SASS_STYLE_NESTED;
ctx
->
options
.
image_path
=
new
char
[
0
];
ctx
->
options
.
output_style
=
args
[
4
]
->
Int32Value
();
ctx
->
options
.
source_comments
=
args
[
5
]
->
Int32Value
();
ctx_w
->
ctx
=
ctx
;
ctx_w
->
ctx
=
ctx
;
extractOptions
(
args
,
ctx
,
ctx_w
,
false
);
ctx_w
->
callback
=
new
NanCallback
(
callback
);
ctx_w
->
errorCallback
=
new
NanCallback
(
errorCallback
);
ctx_w
->
request
.
data
=
ctx_w
;
int
status
=
uv_queue_work
(
uv_default_loop
(),
&
ctx_w
->
request
,
WorkOnContext
,
(
uv_after_work_cb
)
MakeCallback
);
int
status
=
uv_queue_work
(
uv_default_loop
(),
&
ctx_w
->
request
,
WorkOnContext
,
(
uv_after_work_cb
)
MakeCallback
);
assert
(
status
==
0
);
assert
(
status
==
0
);
...
@@ -138,14 +137,28 @@ NAN_METHOD(Render) {
...
@@ -138,14 +137,28 @@ NAN_METHOD(Render) {
NAN_METHOD
(
RenderSync
)
{
NAN_METHOD
(
RenderSync
)
{
NanScope
();
NanScope
();
sass_context
*
ctx
=
sass_new_context
();
sass_context
*
ctx
=
sass_new_context
();
extractOptions
(
args
,
ctx
,
NULL
,
false
);
char
*
source
;
String
::
AsciiValue
astr
(
args
[
0
]);
String
::
AsciiValue
bstr
(
args
[
1
]);
source
=
new
char
[
strlen
(
*
astr
)
+
1
];
strcpy
(
source
,
*
astr
);
ctx
->
source_string
=
source
;
ctx
->
options
.
include_paths
=
new
char
[
strlen
(
*
bstr
)
+
1
];
ctx
->
options
.
include_paths
=
*
bstr
;
ctx
->
options
.
output_style
=
args
[
2
]
->
Int32Value
();
ctx
->
options
.
image_path
=
new
char
[
0
];
ctx
->
options
.
source_comments
=
args
[
3
]
->
Int32Value
();
sass_compile
(
ctx
);
sass_compile
(
ctx
);
source
=
NULL
;
delete
ctx
->
source_string
;
delete
ctx
->
source_string
;
ctx
->
source_string
=
NULL
;
ctx
->
source_string
=
NULL
;
delete
ctx
->
options
.
include_paths
;
delete
ctx
->
options
.
include_paths
;
ctx
->
options
.
include_paths
=
NULL
;
ctx
->
options
.
include_paths
=
NULL
;
delete
ctx
->
options
.
image_path
;
ctx
->
options
.
image_path
=
NULL
;
if
(
ctx
->
error_status
==
0
)
{
if
(
ctx
->
error_status
==
0
)
{
Local
<
Value
>
output
=
NanNewLocal
(
String
::
New
(
ctx
->
output_string
));
Local
<
Value
>
output
=
NanNewLocal
(
String
::
New
(
ctx
->
output_string
));
...
@@ -160,14 +173,71 @@ NAN_METHOD(RenderSync) {
...
@@ -160,14 +173,71 @@ NAN_METHOD(RenderSync) {
NanReturnUndefined
();
NanReturnUndefined
();
}
}
/**
Rendering Files
**/
void
WorkOnFileContext
(
uv_work_t
*
req
)
{
sass_file_context_wrapper
*
ctx_w
=
static_cast
<
sass_file_context_wrapper
*>
(
req
->
data
);
sass_file_context
*
ctx
=
static_cast
<
sass_file_context
*>
(
ctx_w
->
ctx
);
sass_compile_file
(
ctx
);
}
void
MakeFileCallback
(
uv_work_t
*
req
)
{
NanScope
();
TryCatch
try_catch
;
sass_file_context_wrapper
*
ctx_w
=
static_cast
<
sass_file_context_wrapper
*>
(
req
->
data
);
sass_file_context
*
ctx
=
static_cast
<
sass_file_context
*>
(
ctx_w
->
ctx
);
if
(
ctx
->
error_status
==
0
)
{
// if no error, do callback(null, result)
const
unsigned
argc
=
1
;
Local
<
Value
>
argv
[
argc
]
=
{
NanNewLocal
(
String
::
New
(
ctx
->
output_string
))
};
ctx_w
->
callback
->
Call
(
argc
,
argv
);
}
else
{
// if error, do callback(error)
const
unsigned
argc
=
1
;
Local
<
Value
>
argv
[
argc
]
=
{
NanNewLocal
(
String
::
New
(
ctx
->
error_message
))
};
ctx_w
->
errorCallback
->
Call
(
argc
,
argv
);
}
if
(
try_catch
.
HasCaught
())
{
node
::
FatalException
(
try_catch
);
}
delete
ctx
->
input_path
;
sass_free_file_context_wrapper
(
ctx_w
);
}
NAN_METHOD
(
RenderFile
)
{
NAN_METHOD
(
RenderFile
)
{
NanScope
();
NanScope
();
sass_file_context
*
fctx
=
sass_new_file_context
();
sass_file_context
*
ctx
=
sass_new_file_context
();
sass_context_wrapper
*
ctx_w
=
sass_new_context_wrapper
();
sass_file_context_wrapper
*
ctx_w
=
sass_new_file_context_wrapper
();
ctx_w
->
fctx
=
fctx
;
char
*
filename
;
extractOptions
(
args
,
fctx
,
ctx_w
,
true
);
String
::
AsciiValue
astr
(
args
[
0
]);
Local
<
Function
>
callback
=
Local
<
Function
>::
Cast
(
args
[
1
]);
Local
<
Function
>
errorCallback
=
Local
<
Function
>::
Cast
(
args
[
2
]);
String
::
AsciiValue
bstr
(
args
[
3
]);
int
status
=
uv_queue_work
(
uv_default_loop
(),
&
ctx_w
->
request
,
WorkOnContext
,
(
uv_after_work_cb
)
MakeCallback
);
filename
=
new
char
[
strlen
(
*
astr
)
+
1
];
strcpy
(
filename
,
*
astr
);
ctx
->
input_path
=
filename
;
ctx
->
options
.
include_paths
=
new
char
[
strlen
(
*
bstr
)
+
1
];
ctx
->
options
.
include_paths
=
*
bstr
;
// ctx->options.output_style = SASS_STYLE_NESTED;
ctx
->
options
.
output_style
=
args
[
4
]
->
Int32Value
();
ctx
->
options
.
image_path
=
new
char
[
0
];
ctx
->
options
.
source_comments
=
args
[
5
]
->
Int32Value
();
ctx_w
->
ctx
=
ctx
;
ctx_w
->
callback
=
new
NanCallback
(
callback
);
ctx_w
->
errorCallback
=
new
NanCallback
(
errorCallback
);
ctx_w
->
request
.
data
=
ctx_w
;
int
status
=
uv_queue_work
(
uv_default_loop
(),
&
ctx_w
->
request
,
WorkOnFileContext
,
(
uv_after_work_cb
)
MakeFileCallback
);
assert
(
status
==
0
);
assert
(
status
==
0
);
NanReturnUndefined
();
NanReturnUndefined
();
...
@@ -176,14 +246,28 @@ NAN_METHOD(RenderFile) {
...
@@ -176,14 +246,28 @@ NAN_METHOD(RenderFile) {
NAN_METHOD
(
RenderFileSync
)
{
NAN_METHOD
(
RenderFileSync
)
{
NanScope
();
NanScope
();
sass_file_context
*
ctx
=
sass_new_file_context
();
sass_file_context
*
ctx
=
sass_new_file_context
();
extractOptions
(
args
,
ctx
,
NULL
,
true
);
char
*
filename
;
String
::
AsciiValue
astr
(
args
[
0
]);
String
::
AsciiValue
bstr
(
args
[
1
]);
filename
=
new
char
[
strlen
(
*
astr
)
+
1
];
strcpy
(
filename
,
*
astr
);
ctx
->
input_path
=
filename
;
ctx
->
options
.
include_paths
=
new
char
[
strlen
(
*
bstr
)
+
1
];
ctx
->
options
.
include_paths
=
*
bstr
;
ctx
->
options
.
image_path
=
new
char
[
0
];
ctx
->
options
.
output_style
=
args
[
2
]
->
Int32Value
();
ctx
->
options
.
source_comments
=
args
[
3
]
->
Int32Value
();
sass_compile_file
(
ctx
);
sass_compile_file
(
ctx
);
filename
=
NULL
;
delete
ctx
->
input_path
;
delete
ctx
->
input_path
;
ctx
->
input_path
=
NULL
;
ctx
->
input_path
=
NULL
;
delete
ctx
->
options
.
include_paths
;
delete
ctx
->
options
.
include_paths
;
ctx
->
options
.
include_paths
=
NULL
;
ctx
->
options
.
include_paths
=
NULL
;
delete
ctx
->
options
.
image_path
;
ctx
->
options
.
image_path
=
NULL
;
if
(
ctx
->
error_status
==
0
)
{
if
(
ctx
->
error_status
==
0
)
{
Local
<
Value
>
output
=
NanNewLocal
(
String
::
New
(
ctx
->
output_string
));
Local
<
Value
>
output
=
NanNewLocal
(
String
::
New
(
ctx
->
output_string
));
...
@@ -199,6 +283,7 @@ NAN_METHOD(RenderFileSync) {
...
@@ -199,6 +283,7 @@ NAN_METHOD(RenderFileSync) {
}
}
void
RegisterModule
(
v8
::
Handle
<
v8
::
Object
>
target
)
{
void
RegisterModule
(
v8
::
Handle
<
v8
::
Object
>
target
)
{
NODE_SET_METHOD
(
target
,
"oldRender"
,
OldRender
);
NODE_SET_METHOD
(
target
,
"render"
,
Render
);
NODE_SET_METHOD
(
target
,
"render"
,
Render
);
NODE_SET_METHOD
(
target
,
"renderSync"
,
RenderSync
);
NODE_SET_METHOD
(
target
,
"renderSync"
,
RenderSync
);
NODE_SET_METHOD
(
target
,
"renderFile"
,
RenderFile
);
NODE_SET_METHOD
(
target
,
"renderFile"
,
RenderFile
);
...
...
lib/cli.js
View file @
ce2df81d
...
@@ -14,9 +14,6 @@ var optimist = require('optimist')
...
@@ -14,9 +14,6 @@ var optimist = require('optimist')
describe
:
'Include debug info in output (none|normal|map)'
,
describe
:
'Include debug info in output (none|normal|map)'
,
'default'
:
'none'
'default'
:
'none'
})
})
.
options
(
'source-map'
,
{
describe
:
'Emit source map'
})
.
options
(
'include-path'
,
{
.
options
(
'include-path'
,
{
describe
:
'Path to look for @import-ed files'
,
describe
:
'Path to look for @import-ed files'
,
'default'
:
cwd
'default'
:
cwd
...
@@ -102,16 +99,6 @@ exports = module.exports = function(args) {
...
@@ -102,16 +99,6 @@ exports = module.exports = function(args) {
options
.
sourceComments
=
options
.
sourceComments
[
0
];
options
.
sourceComments
=
options
.
sourceComments
[
0
];
}
}
// set source map file and set sourceComments to 'map'
if
(
argv
[
'source-map'
])
{
options
.
sourceComments
=
'map'
;
if
(
argv
[
'source-map'
]
===
true
)
{
options
.
sourceMap
=
outFile
+
'.map'
;
}
else
{
options
.
sourceMap
=
path
.
resolve
(
cwd
,
argv
[
'source-map'
]);
}
}
if
(
argv
.
w
)
{
if
(
argv
.
w
)
{
var
watchDir
=
argv
.
w
;
var
watchDir
=
argv
.
w
;
...
...
lib/render.js
View file @
ce2df81d
...
@@ -9,15 +9,7 @@ function render(options, emitter) {
...
@@ -9,15 +9,7 @@ function render(options, emitter) {
includePaths
:
options
.
includePaths
,
includePaths
:
options
.
includePaths
,
outputStyle
:
options
.
outputStyle
,
outputStyle
:
options
.
outputStyle
,
sourceComments
:
options
.
sourceComments
,
sourceComments
:
options
.
sourceComments
,
sourceMap
:
options
.
sourceMap
,
success
:
function
(
css
)
{
success
:
function
(
css
,
sourceMap
)
{
var
todo
=
1
;
var
done
=
function
()
{
if
(
--
todo
<=
0
)
{
emitter
.
emit
(
'done'
);
}
};
emitter
.
emit
(
'warn'
,
chalk
.
green
(
'Rendering Complete, saving .css file...'
));
emitter
.
emit
(
'warn'
,
chalk
.
green
(
'Rendering Complete, saving .css file...'
));
...
@@ -25,19 +17,8 @@ function render(options, emitter) {
...
@@ -25,19 +17,8 @@ function render(options, emitter) {
if
(
err
)
{
return
emitter
.
emit
(
'error'
,
chalk
.
red
(
'Error: '
+
err
));
}
if
(
err
)
{
return
emitter
.
emit
(
'error'
,
chalk
.
red
(
'Error: '
+
err
));
}
emitter
.
emit
(
'warn'
,
chalk
.
green
(
'Wrote CSS to '
+
options
.
outFile
));
emitter
.
emit
(
'warn'
,
chalk
.
green
(
'Wrote CSS to '
+
options
.
outFile
));
emitter
.
emit
(
'write'
,
err
,
options
.
outFile
,
css
);
emitter
.
emit
(
'write'
,
err
,
options
.
outFile
,
css
);
done
();
});
});
if
(
options
.
sourceMap
)
{
todo
++
;
fs
.
writeFile
(
options
.
sourceMap
,
sourceMap
,
function
(
err
)
{
if
(
err
)
{
return
emitter
.
emit
(
'error'
,
chalk
.
red
(
'Error'
+
err
));
}
emitter
.
emit
(
'warn'
,
chalk
.
green
(
'Wrote Source Map to '
+
options
.
sourceMap
));
emitter
.
emit
(
'write-source-map'
,
err
,
options
.
sourceMap
,
sourceMap
);
done
();
});
}
if
(
options
.
stdout
)
{
if
(
options
.
stdout
)
{
emitter
.
emit
(
'log'
,
css
);
emitter
.
emit
(
'log'
,
css
);
}
}
...
...
sass.js
View file @
ce2df81d
var
binding
;
var
binding
;
var
fs
=
require
(
'fs'
);
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
{
try
{
if
(
fs
.
realpathSync
(
__dirname
+
'/build'
))
{
if
(
fs
.
realpathSync
(
__dirname
+
'/build'
))
{
// use the build version if it exists
// use the build version if it exists
binding
=
require
(
__dirname
+
'/build/Release/binding'
);
binding
=
require
(
__dirname
+
'/build/Release/binding'
);
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
// default to a precompiled binary if no build exists
try
{
var
platform_full
=
process
.
platform
+
'-'
+
process
.
arch
;
fs
.
realpathSync
(
modPath
+
'.node'
);
binding
=
require
(
__dirname
+
'/precompiled/'
+
platform_full
+
'/binding'
);
binding
=
require
(
modPath
);
}
}
catch
(
ex
)
{
if
(
binding
===
null
)
{
// No binary!
throw
new
Error
(
'Cannot find appropriate binary library for node-sass'
);
throw
new
Error
(
'`'
+
modPath
+
'.node` is missing. Try reinstalling `node-sass`?'
);
}
}
}
var
SASS_OUTPUT_STYLE
=
{
var
SASS_OUTPUT_STYLE
=
{
...
@@ -29,11 +34,11 @@ var SASS_SOURCE_COMMENTS = {
...
@@ -29,11 +34,11 @@ var SASS_SOURCE_COMMENTS = {
};
};
var
prepareOptions
=
function
(
options
)
{
var
prepareOptions
=
function
(
options
)
{
var
paths
,
style
,
comments
;
var
paths
,
style
;
options
=
typeof
options
!==
'object'
?
{}
:
options
;
var
options
=
typeof
options
!==
'object'
?
{}
:
options
;
paths
=
options
.
include_paths
||
options
.
includePaths
||
[];
var
paths
=
options
.
include_paths
||
options
.
includePaths
||
[];
style
=
SASS_OUTPUT_STYLE
[
options
.
output_style
||
options
.
outputStyle
]
||
0
;
var
style
=
SASS_OUTPUT_STYLE
[
options
.
output_style
||
options
.
outputStyle
]
||
0
;
comments
=
SASS_SOURCE_COMMENTS
[
options
.
source_comments
||
options
.
sourceComments
]
||
0
;
var
comments
=
SASS_SOURCE_COMMENTS
[
options
.
source_comments
||
options
.
sourceComments
]
||
0
;
return
{
return
{
paths
:
paths
,
paths
:
paths
,
...
@@ -44,13 +49,7 @@ var prepareOptions = function(options) {
...
@@ -44,13 +49,7 @@ var prepareOptions = function(options) {
var
deprecatedRender
=
function
(
css
,
callback
,
options
)
{
var
deprecatedRender
=
function
(
css
,
callback
,
options
)
{
options
=
prepareOptions
(
options
);
options
=
prepareOptions
(
options
);
var
errCallback
=
function
(
err
)
{
return
binding
.
oldRender
(
css
,
callback
,
options
.
paths
.
join
(
':'
),
options
.
style
,
options
.
comments
);
callback
(
err
);
};
var
oldCallback
=
function
(
css
,
err
)
{
callback
(
null
,
css
);
};
return
binding
.
render
(
css
,
oldCallback
,
errCallback
,
options
.
paths
.
join
(
':'
),
options
.
style
,
options
.
comments
);
};
};
var
deprecatedRenderSync
=
function
(
css
,
options
)
{
var
deprecatedRenderSync
=
function
(
css
,
options
)
{
...
@@ -69,11 +68,11 @@ exports.render = function(options) {
...
@@ -69,11 +68,11 @@ exports.render = function(options) {
options
.
error
=
options
.
error
||
function
(){};
options
.
error
=
options
.
error
||
function
(){};
if
(
options
.
file
!==
undefined
&&
options
.
file
!==
null
)
{
if
(
options
.
file
!==
undefined
&&
options
.
file
!==
null
)
{
return
binding
.
renderFile
(
options
.
file
,
options
.
success
,
options
.
error
,
newOptions
.
paths
.
join
(
':'
),
newOptions
.
style
,
newOptions
.
comments
,
options
.
sourceMap
);
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!
//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
)
{
exports
.
renderSync
=
function
(
options
)
{
...
@@ -86,11 +85,11 @@ exports.renderSync = function(options) {
...
@@ -86,11 +85,11 @@ exports.renderSync = function(options) {
newOptions
=
prepareOptions
(
options
);
newOptions
=
prepareOptions
(
options
);
if
(
options
.
file
!==
undefined
&&
options
.
file
!==
null
)
{
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!
//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'
);
exports
.
middleware
=
require
(
'./lib/middleware'
);
sass_context_wrapper.cpp
View file @
ce2df81d
...
@@ -12,7 +12,21 @@ extern "C" {
...
@@ -12,7 +12,21 @@ extern "C" {
void
sass_free_context_wrapper
(
sass_context_wrapper
*
ctx_w
)
void
sass_free_context_wrapper
(
sass_context_wrapper
*
ctx_w
)
{
{
if
(
ctx_w
->
ctx
)
sass_free_context
(
ctx_w
->
ctx
);
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
->
callback
;
delete
ctx_w
->
errorCallback
;
delete
ctx_w
->
errorCallback
;
...
...
sass_context_wrapper.h
View file @
ce2df81d
...
@@ -7,7 +7,6 @@ extern "C" {
...
@@ -7,7 +7,6 @@ extern "C" {
struct
sass_context_wrapper
{
struct
sass_context_wrapper
{
sass_context
*
ctx
;
sass_context
*
ctx
;
sass_file_context
*
fctx
;
uv_work_t
request
;
uv_work_t
request
;
NanCallback
*
callback
;
NanCallback
*
callback
;
NanCallback
*
errorCallback
;
NanCallback
*
errorCallback
;
...
@@ -16,6 +15,16 @@ struct sass_context_wrapper {
...
@@ -16,6 +15,16 @@ struct sass_context_wrapper {
struct
sass_context_wrapper
*
sass_new_context_wrapper
(
void
);
struct
sass_context_wrapper
*
sass_new_context_wrapper
(
void
);
void
sass_free_context_wrapper
(
struct
sass_context_wrapper
*
ctx
);
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
#ifdef __cplusplus
}
}
#endif
#endif
test/cli.js
View file @
ce2df81d
...
@@ -103,40 +103,4 @@ describe('cli', function() {
...
@@ -103,40 +103,4 @@ describe('cli', function() {
});
});
});
});
it
(
'should compile with the --source-map option'
,
function
(
done
){
var
emitter
=
cli
([
path
.
join
(
__dirname
,
'sample.scss'
),
'--source-map'
]);
emitter
.
on
(
'error'
,
done
);
emitter
.
on
(
'write-source-map'
,
function
(
err
,
file
)
{
assert
.
equal
(
file
,
path
.
join
(
__dirname
,
'../sample.css.map'
));
fs
.
exists
(
file
,
function
(
exists
)
{
assert
(
exists
);
});
});
emitter
.
on
(
'done'
,
function
()
{
fs
.
unlink
(
path
.
join
(
__dirname
,
'../sample.css.map'
),
function
()
{
fs
.
unlink
(
path
.
join
(
__dirname
,
'../sample.css'
),
function
()
{
done
();
});
});
});
});
it
(
'should compile with the --source-map option with specific filename'
,
function
(
done
){
var
emitter
=
cli
([
path
.
join
(
__dirname
,
'sample.scss'
),
'--source-map'
,
path
.
join
(
__dirname
,
'../sample.map'
)]);
emitter
.
on
(
'error'
,
done
);
emitter
.
on
(
'write-source-map'
,
function
(
err
,
file
)
{
assert
.
equal
(
file
,
path
.
join
(
__dirname
,
'../sample.map'
));
fs
.
exists
(
file
,
function
(
exists
)
{
assert
(
exists
);
});
});
emitter
.
on
(
'done'
,
function
()
{
fs
.
unlink
(
path
.
join
(
__dirname
,
'../sample.map'
),
function
()
{
fs
.
unlink
(
path
.
join
(
__dirname
,
'../sample.css'
),
function
()
{
done
();
});
});
});
});
});
});
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