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
Expand all
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
This diff is collapsed.
Click to expand it.
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