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
a956d188
Commit
a956d188
authored
Jan 06, 2015
by
Adeel Mujahid
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #589 from am11/master
Importer: General overhauling
parents
f7a2ee52
84fe3fee
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
139 additions
and
200 deletions
+139
-200
node-sass
bin/node-sass
+4
-8
index.js
lib/index.js
+27
-18
render.js
lib/render.js
+3
-3
build.js
scripts/build.js
+0
-1
binding.cpp
src/binding.cpp
+86
-76
libsass
src/libsass
+1
-1
sass_context_wrapper.cpp
src/sass_context_wrapper.cpp
+12
-3
sass_context_wrapper.h
src/sass_context_wrapper.h
+3
-1
api.js
test/api.js
+0
-86
my_custom_importer_file.js
test/fixtures/extras/my_custom_importer_file.js
+1
-1
expected.map
test/fixtures/source-map/expected.map
+1
-1
spec
test/fixtures/spec
+1
-1
No files found.
bin/node-sass
View file @
a956d188
...
...
@@ -5,8 +5,7 @@ var Emitter = require('events').EventEmitter,
meow
=
require
(
'meow'
),
replaceExt
=
require
(
'replace-ext'
),
stdin
=
require
(
'get-stdin'
),
render
=
require
(
'../lib/render'
),
fs
=
require
(
'fs'
);
render
=
require
(
'../lib/render'
);
/**
* Initialize CLI
...
...
@@ -109,9 +108,7 @@ function getEmitter() {
console
.
log
(
data
);
});
emitter
.
on
(
'done'
,
function
(){
process
.
exit
(
0
);
});
emitter
.
on
(
'done'
,
process
.
exit
);
return
emitter
;
}
...
...
@@ -211,11 +208,10 @@ function run(options, emitter) {
}
if
(
options
.
importer
)
{
if
(
fs
.
existsSync
(
options
.
importer
))
{
if
(
(
path
.
resolve
(
options
.
importer
)
===
path
.
normalize
(
options
.
importer
).
replace
(
/
(
.+
)([\/
|
\\])
$/
,
'$1'
)
))
{
options
.
importer
=
require
(
options
.
importer
);
}
else
{
console
.
error
(
'Could not locate importer.'
);
process
.
exit
(
1
);
options
.
importer
=
require
(
path
.
resolve
(
process
.
cwd
(),
options
.
importer
));
}
}
...
...
lib/index.js
View file @
a956d188
...
...
@@ -144,7 +144,6 @@ function getOptions(options) {
var
error
=
options
.
error
;
var
success
=
options
.
success
;
var
importer
=
options
.
importer
;
options
.
error
=
function
(
err
,
code
)
{
try
{
...
...
@@ -173,23 +172,6 @@ function getOptions(options) {
}
};
if
(
importer
)
{
options
.
importer
=
function
(
file
,
prev
,
key
)
{
var
done
=
function
(
data
)
{
binding
.
importedCallback
({
index
:
key
,
objectLiteral
:
data
});
};
var
result
=
importer
(
file
,
prev
,
done
);
if
(
result
)
{
done
(
result
);
}
};
}
delete
options
.
image_path
;
delete
options
.
include_paths
;
delete
options
.
includePaths
;
...
...
@@ -219,6 +201,25 @@ var binding = require(getBinding());
module
.
exports
.
render
=
function
(
options
)
{
options
=
getOptions
(
options
);
var
importer
=
options
.
importer
;
if
(
importer
)
{
options
.
importer
=
function
(
file
,
prev
,
key
)
{
function
done
(
data
)
{
binding
.
importedCallback
({
index
:
key
,
objectLiteral
:
data
});
}
var
result
=
importer
(
file
,
prev
,
done
);
if
(
result
)
{
done
(
result
);
}
};
}
options
.
data
?
binding
.
render
(
options
)
:
binding
.
renderFile
(
options
);
};
...
...
@@ -232,6 +233,14 @@ module.exports.render = function(options) {
module
.
exports
.
renderSync
=
function
(
options
)
{
options
=
getOptions
(
options
);
var
importer
=
options
.
importer
;
if
(
importer
)
{
options
.
importer
=
function
(
file
,
prev
)
{
return
{
objectLiteral
:
importer
(
file
,
prev
)
};
};
}
var
status
=
options
.
data
?
binding
.
renderSync
(
options
)
:
binding
.
renderFileSync
(
options
);
var
result
=
options
.
result
;
...
...
lib/render.js
View file @
a956d188
...
...
@@ -28,10 +28,10 @@ module.exports = function(options, emitter) {
importer
:
options
.
importer
};
if
(
options
.
src
)
{
renderOptions
.
file
=
options
.
src
;
}
else
if
(
options
.
data
)
{
if
(
options
.
data
)
{
renderOptions
.
data
=
options
.
data
;
}
else
if
(
options
.
src
)
{
renderOptions
.
file
=
options
.
src
;
}
renderOptions
.
success
=
function
(
result
)
{
...
...
scripts/build.js
View file @
a956d188
...
...
@@ -124,7 +124,6 @@ function testBinary(options) {
return
build
(
options
);
}
return
;
// TODO: remove it once TravisCI build pass 90% and above tests
console
.
log
(
'`'
+
options
.
bin
+
'` exists; testing'
);
var
total
;
...
...
src/binding.cpp
View file @
a956d188
...
...
@@ -4,7 +4,7 @@
char
*
CreateString
(
Local
<
Value
>
value
)
{
if
(
value
->
IsNull
()
||
!
value
->
IsString
())
{
return
const_cast
<
char
*>
(
""
);
// return empty string.
return
0
;
}
String
::
Utf8Value
string
(
value
);
...
...
@@ -15,6 +15,41 @@ char* CreateString(Local<Value> value) {
std
::
vector
<
sass_context_wrapper
*>
imports_collection
;
void
prepare_import_results
(
Local
<
Value
>
returned_value
,
sass_context_wrapper
*
ctx_w
)
{
NanScope
();
if
(
returned_value
->
IsArray
())
{
Handle
<
Array
>
array
=
Handle
<
Array
>::
Cast
(
returned_value
);
ctx_w
->
imports
=
sass_make_import_list
(
array
->
Length
());
for
(
size_t
i
=
0
;
i
<
array
->
Length
();
++
i
)
{
Local
<
Value
>
value
=
array
->
Get
(
i
);
if
(
!
value
->
IsObject
())
continue
;
Local
<
Object
>
object
=
Local
<
Object
>::
Cast
(
value
);
char
*
path
=
CreateString
(
object
->
Get
(
String
::
New
(
"file"
)));
char
*
contents
=
CreateString
(
object
->
Get
(
String
::
New
(
"contents"
)));
ctx_w
->
imports
[
i
]
=
sass_make_import_entry
(
path
,
(
!
contents
||
contents
[
0
]
==
'\0'
)
?
0
:
strdup
(
contents
),
0
);
}
}
else
if
(
returned_value
->
IsObject
())
{
ctx_w
->
imports
=
sass_make_import_list
(
1
);
Local
<
Object
>
object
=
Local
<
Object
>::
Cast
(
returned_value
);
char
*
path
=
CreateString
(
object
->
Get
(
String
::
New
(
"file"
)));
char
*
contents
=
CreateString
(
object
->
Get
(
String
::
New
(
"contents"
)));
ctx_w
->
imports
[
0
]
=
sass_make_import_entry
(
path
,
(
!
contents
||
contents
[
0
]
==
'\0'
)
?
0
:
strdup
(
contents
),
0
);
}
else
{
ctx_w
->
imports
=
sass_make_import_list
(
1
);
ctx_w
->
imports
[
0
]
=
sass_make_import_entry
(
ctx_w
->
file
,
0
,
0
);
}
}
void
dispatched_async_uv_callback
(
uv_async_t
*
req
)
{
NanScope
();
sass_context_wrapper
*
ctx_w
=
static_cast
<
sass_context_wrapper
*>
(
req
->
data
);
...
...
@@ -40,45 +75,57 @@ struct Sass_Import** sass_importer(const char* file, const char* prev, void* coo
{
sass_context_wrapper
*
ctx_w
=
static_cast
<
sass_context_wrapper
*>
(
cookie
);
ctx_w
->
file
=
file
?
strdup
(
file
)
:
0
;
ctx_w
->
prev
=
prev
?
strdup
(
prev
)
:
0
;
ctx_w
->
async
.
data
=
(
void
*
)
ctx_w
;
uv_async_send
(
&
ctx_w
->
async
);
if
(
ctx_w
->
success_callback
)
{
if
(
!
ctx_w
->
is_sync
)
{
/* that is async: Render() or RenderFile(),
* the default even loop is unblocked so it
* can run uv_async_send without a push.
*/
ctx_w
->
file
=
file
?
strdup
(
file
)
:
0
;
ctx_w
->
prev
=
prev
?
strdup
(
prev
)
:
0
;
ctx_w
->
async
.
data
=
(
void
*
)
ctx_w
;
uv_async_send
(
&
ctx_w
->
async
);
uv_cond_wait
(
&
ctx_w
->
importer_condition_variable
,
&
ctx_w
->
importer_mutex
);
}
else
{
/* that is sync: RenderSync() or RenderFileSync,
* we need to explicitly uv_run as the event loop
* is blocked; waiting down the chain.
*/
uv_run
(
ctx_w
->
async
.
loop
,
UV_RUN_DEFAULT
);
NanScope
();
Handle
<
Value
>
argv
[]
=
{
NanNew
<
String
>
(
file
),
NanNew
<
String
>
(
prev
),
NanNew
<
Number
>
(
imports_collection
.
size
()
-
1
)
};
Local
<
Object
>
returned_value
=
Local
<
Object
>::
Cast
(
NanNew
<
Value
>
(
ctx_w
->
importer_callback
->
Call
(
3
,
argv
)));
prepare_import_results
(
returned_value
->
Get
(
NanNew
(
"objectLiteral"
)),
ctx_w
);
}
return
ctx_w
->
imports
;
}
void
ExtractOptions
(
Local
<
Object
>
options
,
void
*
cptr
,
sass_context_wrapper
*
ctx_w
,
bool
isFile
,
bool
isSync
)
{
NanScope
();
struct
Sass_Context
*
ctx
;
NanAssignPersistent
(
ctx_w
->
result
,
options
->
Get
(
NanNew
(
"result"
))
->
ToObject
());
if
(
isFile
)
{
ctx
=
sass_file_context_get_context
((
struct
Sass_File_Context
*
)
cptr
);
ctx_w
->
fctx
=
(
struct
Sass_File_Context
*
)
cptr
;
ctx
=
sass_file_context_get_context
(
ctx_w
->
fctx
);
}
else
{
ctx
=
sass_data_context_get_context
((
struct
Sass_Data_Context
*
)
cptr
);
ctx_w
->
dctx
=
(
struct
Sass_Data_Context
*
)
cptr
;
ctx
=
sass_data_context_get_context
(
ctx_w
->
dctx
);
}
struct
Sass_Options
*
sass_options
=
sass_context_get_options
(
ctx
);
ctx_w
->
importer_callback
=
NULL
;
ctx_w
->
is_sync
=
isSync
;
if
(
!
isSync
)
{
ctx_w
->
request
.
data
=
ctx_w
;
...
...
@@ -92,14 +139,16 @@ void ExtractOptions(Local<Object> options, void* cptr, sass_context_wrapper* ctx
Local
<
Function
>
importer_callback
=
Local
<
Function
>::
Cast
(
options
->
Get
(
NanNew
(
"importer"
)));
ctx_w
->
importer_callback
=
new
NanCallback
(
importer_callback
);
if
(
!
importer_callback
->
IsUndefined
())
{
if
(
importer_callback
->
IsFunction
())
{
ctx_w
->
importer_callback
=
new
NanCallback
(
importer_callback
);
uv_async_init
(
uv_default_loop
(),
&
ctx_w
->
async
,
(
uv_async_cb
)
dispatched_async_uv_callback
);
sass_option_set_importer
(
sass_options
,
sass_make_importer
(
sass_importer
,
ctx_w
));
}
sass_option_set_input_path
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"file"
))));
if
(
!
isFile
)
{
sass_option_set_input_path
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"file"
))));
}
sass_option_set_output_path
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"outFile"
))));
sass_option_set_image_path
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"imagePath"
))));
sass_option_set_output_style
(
sass_options
,
(
Sass_Output_Style
)
options
->
Get
(
NanNew
(
"style"
))
->
Int32Value
());
...
...
@@ -114,6 +163,8 @@ void ExtractOptions(Local<Object> options, void* cptr, sass_context_wrapper* ctx
}
void
GetStats
(
sass_context_wrapper
*
ctx_w
,
Sass_Context
*
ctx
)
{
NanScope
();
char
**
included_files
=
sass_context_get_included_files
(
ctx
);
Handle
<
Array
>
arr
=
NanNew
<
Array
>
();
...
...
@@ -123,13 +174,12 @@ void GetStats(sass_context_wrapper* ctx_w, Sass_Context* ctx) {
}
}
Local
<
Object
>
obj
=
NanNew
(
ctx_w
->
result
);
obj
->
Get
(
NanNew
(
"stats"
))
->
ToObject
()
->
Set
(
NanNew
(
"includedFiles"
),
arr
);
NanAssignPersistent
(
ctx_w
->
result
,
obj
);
NanNew
(
ctx_w
->
result
)
->
Get
(
NanNew
(
"stats"
))
->
ToObject
()
->
Set
(
NanNew
(
"includedFiles"
),
arr
);
}
void
GetSourceMap
(
sass_context_wrapper
*
ctx_w
,
Sass_Context
*
ctx
)
{
NanScope
();
Handle
<
Value
>
source_map
;
if
(
sass_context_get_error_status
(
ctx
))
{
...
...
@@ -143,20 +193,16 @@ void GetSourceMap(sass_context_wrapper* ctx_w, Sass_Context* ctx) {
source_map
=
NanNew
<
String
>
(
"{}"
);
}
Local
<
Object
>
obj
=
NanNew
(
ctx_w
->
result
);
obj
->
Set
(
NanNew
(
"sourceMap"
),
source_map
);
NanAssignPersistent
(
ctx_w
->
result
,
obj
);
NanNew
(
ctx_w
->
result
)
->
Set
(
NanNew
(
"sourceMap"
),
source_map
);
}
int
GetResult
(
sass_context_wrapper
*
ctx_w
,
Sass_Context
*
ctx
)
{
NanScope
();
int
status
=
sass_context_get_error_status
(
ctx
);
if
(
status
==
0
)
{
Local
<
Object
>
obj
=
NanNew
(
ctx_w
->
result
);
obj
->
Set
(
NanNew
(
"css"
),
NanNew
<
String
>
(
sass_context_get_output_string
(
ctx
)));
NanAssignPersistent
(
ctx_w
->
result
,
obj
);
NanNew
(
ctx_w
->
result
)
->
Set
(
NanNew
(
"css"
),
NanNew
<
String
>
(
sass_context_get_output_string
(
ctx
)));
GetStats
(
ctx_w
,
ctx
);
GetSourceMap
(
ctx_w
,
ctx
);
...
...
@@ -181,11 +227,11 @@ void make_callback(uv_work_t* req) {
int
status
=
GetResult
(
ctx_w
,
ctx
);
if
(
status
==
0
)
{
if
(
status
==
0
&&
ctx_w
->
success_callback
)
{
// if no error, do callback(null, result)
ctx_w
->
success_callback
->
Call
(
0
,
0
);
}
else
{
else
if
(
ctx_w
->
error_callback
)
{
// if error, do callback(error)
const
char
*
err
=
sass_context_get_error_json
(
ctx
);
Local
<
Value
>
argv
[]
=
{
...
...
@@ -198,6 +244,10 @@ void make_callback(uv_work_t* req) {
node
::
FatalException
(
try_catch
);
}
if
(
ctx_w
->
importer_callback
)
{
uv_close
((
uv_handle_t
*
)
&
ctx_w
->
async
,
NULL
);
}
sass_free_context_wrapper
(
ctx_w
);
}
...
...
@@ -228,6 +278,7 @@ NAN_METHOD(RenderSync) {
sass_context_wrapper
*
ctx_w
=
sass_make_context_wrapper
();
ExtractOptions
(
options
,
dctx
,
ctx_w
,
false
,
true
);
compile_data
(
dctx
);
int
result
=
GetResult
(
ctx_w
,
ctx
);
...
...
@@ -237,8 +288,7 @@ NAN_METHOD(RenderSync) {
error
=
NanNew
<
String
>
(
sass_context_get_error_json
(
ctx
));
}
sass_free_context_wrapper
(
ctx_w
);
free
(
source_string
);
sass_wrapper_dispose
(
ctx_w
,
source_string
);
if
(
result
!=
0
)
{
NanThrowError
(
error
);
...
...
@@ -260,7 +310,6 @@ NAN_METHOD(RenderFile) {
int
status
=
uv_queue_work
(
uv_default_loop
(),
&
ctx_w
->
request
,
compile_it
,
(
uv_after_work_cb
)
make_callback
);
assert
(
status
==
0
);
free
(
input_path
);
NanReturnUndefined
();
}
...
...
@@ -284,8 +333,7 @@ NAN_METHOD(RenderFileSync) {
error
=
NanNew
<
String
>
(
sass_context_get_error_json
(
ctx
));
}
sass_free_context_wrapper
(
ctx_w
);
free
(
input_path
);
sass_wrapper_dispose
(
ctx_w
,
input_path
);
if
(
result
!=
0
)
{
NanThrowError
(
error
);
...
...
@@ -309,51 +357,13 @@ NAN_METHOD(ImportedCallback) {
sass_context_wrapper
*
ctx_w
=
imports_collection
[
index
];
if
(
returned_value
->
IsArray
())
{
Handle
<
Array
>
array
=
Handle
<
Array
>::
Cast
(
returned_value
);
ctx_w
->
imports
=
sass_make_import_list
(
array
->
Length
());
for
(
size_t
i
=
0
;
i
<
array
->
Length
();
++
i
)
{
Local
<
Value
>
value
=
array
->
Get
(
i
);
if
(
!
value
->
IsObject
())
continue
;
Local
<
Object
>
object
=
Local
<
Object
>::
Cast
(
value
);
char
*
path
=
CreateString
(
object
->
Get
(
String
::
New
(
"file"
)));
char
*
contents
=
CreateString
(
object
->
Get
(
String
::
New
(
"contents"
)));
ctx_w
->
imports
[
i
]
=
sass_make_import_entry
(
path
,
(
!
contents
||
contents
[
0
]
==
'\0'
)
?
0
:
strdup
(
contents
),
0
);
}
}
else
if
(
returned_value
->
IsObject
())
{
ctx_w
->
imports
=
sass_make_import_list
(
1
);
Local
<
Object
>
object
=
Local
<
Object
>::
Cast
(
returned_value
);
char
*
path
=
CreateString
(
object
->
Get
(
String
::
New
(
"file"
)));
char
*
contents
=
CreateString
(
object
->
Get
(
String
::
New
(
"contents"
)));
ctx_w
->
imports
[
0
]
=
sass_make_import_entry
(
path
,
(
!
contents
||
contents
[
0
]
==
'\0'
)
?
0
:
strdup
(
contents
),
0
);
}
else
{
ctx_w
->
imports
=
sass_make_import_list
(
1
);
ctx_w
->
imports
[
0
]
=
sass_make_import_entry
(
ctx_w
->
file
,
0
,
0
);
}
prepare_import_results
(
returned_value
,
ctx_w
);
uv_cond_signal
(
&
ctx_w
->
importer_condition_variable
);
if
(
try_catch
.
HasCaught
())
{
node
::
FatalException
(
try_catch
);
}
if
(
!
ctx_w
->
success_callback
)
{
/*
* that is sync: RenderSync() or RenderFileSync,
* we ran it explictly, so we stop it similarly.
*/
uv_stop
(
ctx_w
->
async
.
loop
);
}
NanReturnValue
(
NanNew
<
Number
>
(
0
));
}
...
...
libsass
@
31521ef3
Subproject commit
cf7c1d14fec91a66ab9c2a3050dcec5fab6198f5
Subproject commit
31521ef3ece636892f395a80392448ceae449b90
src/sass_context_wrapper.cpp
View file @
a956d188
...
...
@@ -4,7 +4,7 @@ extern "C" {
using
namespace
std
;
void
compile_it
(
uv_work_t
*
req
)
{
sass_context_wrapper
*
ctx_w
=
static_cast
<
sass_context_wrapper
*>
(
req
->
data
)
;
sass_context_wrapper
*
ctx_w
=
(
sass_context_wrapper
*
)
req
->
data
;
if
(
ctx_w
->
dctx
)
{
compile_data
(
ctx_w
->
dctx
);
...
...
@@ -23,13 +23,14 @@ extern "C" {
}
sass_context_wrapper
*
sass_make_context_wrapper
()
{
auto
ctx_w
=
(
sass_context_wrapper
*
)
calloc
(
1
,
sizeof
(
sass_context_wrapper
));
sass_context_wrapper
*
ctx_w
=
(
sass_context_wrapper
*
)
calloc
(
1
,
sizeof
(
sass_context_wrapper
));
uv_mutex_init
(
&
ctx_w
->
importer_mutex
);
uv_cond_init
(
&
ctx_w
->
importer_condition_variable
);
return
ctx_w
;
}
void
sass_
free_context_wrapper
(
sass_context_wrapper
*
ctx_w
)
{
void
sass_
wrapper_dispose
(
struct
sass_context_wrapper
*
ctx_w
,
char
*
string
=
0
)
{
if
(
ctx_w
->
dctx
)
{
sass_delete_data_context
(
ctx_w
->
dctx
);
}
...
...
@@ -48,6 +49,14 @@ extern "C" {
NanDisposePersistent
(
ctx_w
->
result
);
if
(
string
)
{
free
(
string
);
}
}
void
sass_free_context_wrapper
(
sass_context_wrapper
*
ctx_w
)
{
sass_wrapper_dispose
(
ctx_w
);
free
(
ctx_w
);
}
}
src/sass_context_wrapper.h
View file @
a956d188
...
...
@@ -22,6 +22,7 @@ extern "C" {
const
char
*
file
;
const
char
*
prev
;
void
*
cookie
;
bool
is_sync
;
Sass_Import
**
imports
;
NanCallback
*
success_callback
;
NanCallback
*
error_callback
;
...
...
@@ -29,7 +30,8 @@ extern "C" {
};
struct
sass_context_wrapper
*
sass_make_context_wrapper
(
void
);
void
sass_free_context_wrapper
(
struct
sass_context_wrapper
*
ctx_w
);
void
sass_wrapper_dispose
(
struct
sass_context_wrapper
*
,
char
*
);
void
sass_free_context_wrapper
(
struct
sass_context_wrapper
*
);
#ifdef __cplusplus
}
...
...
test/api.js
View file @
a956d188
...
...
@@ -364,36 +364,6 @@ describe('api', function() {
describe
(
'.renderSync(importer)'
,
function
()
{
var
src
=
read
(
fixture
(
'include-files/index.scss'
),
'utf8'
);
it
(
'should override imports with "data" as input and fires callback with file and contents'
,
function
(
done
)
{
var
result
=
sass
.
renderSync
({
data
:
src
,
importer
:
function
(
url
,
prev
,
done
)
{
done
({
file
:
'/some/other/path.scss'
,
contents
:
'div {color: yellow;}'
});
}
});
assert
.
equal
(
result
.
css
.
trim
(),
'div {
\
n color: yellow; }
\
n
\
ndiv {
\
n color: yellow; }'
);
done
();
});
it
(
'should override imports with "file" as input and fires callback with file and contents'
,
function
(
done
)
{
var
result
=
sass
.
renderSync
({
file
:
fixture
(
'include-files/index.scss'
),
importer
:
function
(
url
,
prev
,
done
)
{
done
({
file
:
'/some/other/path.scss'
,
contents
:
'div {color: yellow;}'
});
}
});
assert
.
equal
(
result
.
css
.
trim
(),
'div {
\
n color: yellow; }
\
n
\
ndiv {
\
n color: yellow; }'
);
done
();
});
it
(
'should override imports with "data" as input and returns file and contents'
,
function
(
done
)
{
var
result
=
sass
.
renderSync
({
data
:
src
,
...
...
@@ -424,34 +394,6 @@ describe('api', function() {
done
();
});
it
(
'should override imports with "data" as input and fires callback with file'
,
function
(
done
)
{
var
result
=
sass
.
renderSync
({
data
:
src
,
importer
:
function
(
url
,
/* jshint unused:false */
prev
,
done
)
{
done
({
file
:
path
.
resolve
(
path
.
dirname
(
fixture
(
'include-files/index.scss'
)),
url
+
(
path
.
extname
(
url
)
?
''
:
'.scss'
))
});
}
});
assert
.
equal
(
result
.
css
.
trim
(),
''
);
done
();
});
it
(
'should override imports with "file" as input and fires callback with file'
,
function
(
done
)
{
var
result
=
sass
.
renderSync
({
file
:
fixture
(
'include-files/index.scss'
),
importer
:
function
(
url
,
prev
,
done
)
{
done
({
file
:
path
.
resolve
(
path
.
dirname
(
prev
),
url
+
(
path
.
extname
(
url
)
?
''
:
'.scss'
))
});
}
});
assert
.
equal
(
result
.
css
.
trim
(),
''
);
done
();
});
it
(
'should override imports with "data" as input and returns file'
,
function
(
done
)
{
var
result
=
sass
.
renderSync
({
data
:
src
,
...
...
@@ -480,34 +422,6 @@ describe('api', function() {
done
();
});
it
(
'should override imports with "data" as input and fires callback with contents'
,
function
(
done
)
{
var
result
=
sass
.
renderSync
({
data
:
src
,
importer
:
function
(
url
,
prev
,
done
)
{
done
({
contents
:
'div {color: yellow;}'
});
}
});
assert
.
equal
(
result
.
css
.
trim
(),
'div {
\
n color: yellow; }
\
n
\
ndiv {
\
n color: yellow; }'
);
done
();
});
it
(
'should override imports with "file" as input and fires callback with contents'
,
function
(
done
)
{
var
result
=
sass
.
renderSync
({
file
:
fixture
(
'include-files/index.scss'
),
importer
:
function
(
url
,
prev
,
done
)
{
done
({
contents
:
'div {color: yellow;}'
});
}
});
assert
.
equal
(
result
.
css
.
trim
(),
'div {
\
n color: yellow; }
\
n
\
ndiv {
\
n color: yellow; }'
);
done
();
});
it
(
'should override imports with "data" as input and returns contents'
,
function
(
done
)
{
var
result
=
sass
.
renderSync
({
data
:
src
,
...
...
test/fixtures/extras/my_custom_importer_file.js
View file @
a956d188
var
path
=
require
(
'path'
);
module
.
exports
=
function
(
file
)
{
console
.
log
(
'>>>>>>>>>>'
);
console
.
log
(
path
.
resolve
(
path
.
join
(
process
.
cwd
(),
'test/fixtures/include-files/'
,
file
+
(
path
.
extname
(
file
)
?
''
:
'.scss'
))));
module
.
exports
=
function
(
file
)
{
return
{
file
:
path
.
resolve
(
path
.
join
(
process
.
cwd
(),
'test/fixtures/include-files/'
,
file
+
(
path
.
extname
(
file
)
?
''
:
'.scss'
)))
};
...
...
test/fixtures/source-map/expected.map
View file @
a956d188
...
...
@@ -5,6 +5,6 @@
"index.scss"
],
"sourcesContent": [],
"mappings": "AAAA;EACE,AAAO;EACP,AAAQ;;AAGV,AAAQ;EACN,AAAiB;;AAGnB,AAAQ;EACN,AAAO;EA
AT,AAAQ,AAAG;IAG
P,AAAa",
"mappings": "AAAA;EACE,AAAO;EACP,AAAQ;;AAGV,AAAQ;EACN,AAAiB;;AAGnB,AAAQ;EACN,AAAO;EA
ET,AAAQ,AAAG;IAC
P,AAAa",
"names": []
}
spec
@
3dc1f575
Subproject commit
00c6154dba85a38bb03b89d7279f439feb055821
Subproject commit
3dc1f5758786627f41cebd275238d9224a593e5f
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