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
3ff1d6f9
Commit
3ff1d6f9
authored
Jun 19, 2014
by
Andrew Nesbitt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #356 from blopker/master
Don't write to disk with --stdout
parents
6d507401
7265e7b0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
11 deletions
+28
-11
render.js
lib/render.js
+7
-4
cli.js
test/cli.js
+21
-7
No files found.
lib/render.js
View file @
3ff1d6f9
...
...
@@ -21,6 +21,13 @@ function render(options, emitter) {
}
};
// Write to stdout
if
(
options
.
stdout
)
{
emitter
.
emit
(
'log'
,
css
);
return
done
();
}
// Write to disk
emitter
.
emit
(
'warn'
,
chalk
.
green
(
'Rendering Complete, saving .css file...'
));
fs
.
writeFile
(
options
.
outFile
,
css
,
function
(
err
)
{
...
...
@@ -40,10 +47,6 @@ function render(options, emitter) {
});
}
if
(
options
.
stdout
)
{
emitter
.
emit
(
'log'
,
css
);
}
emitter
.
emit
(
'render'
,
css
);
},
error
:
function
(
error
)
{
...
...
test/cli.js
View file @
3ff1d6f9
...
...
@@ -28,6 +28,8 @@ var expectedSampleCustomImagePath = 'body {\n\
background-image: url("/path/to/images/image.png"); }
\
n'
;
var
sampleScssPath
=
path
.
join
(
__dirname
,
'sample.scss'
);
var
sampleCssOutputPath
=
path
.
join
(
__dirname
,
'../sample.css'
);
var
sampleCssMapOutputPath
=
path
.
join
(
__dirname
,
'../sample.css.map'
);
describe
(
'cli'
,
function
()
{
it
(
'should print help when run with no arguments'
,
function
(
done
)
{
...
...
@@ -127,6 +129,18 @@ describe('cli', function() {
});
});
it
(
'should not write to disk with the --stdout option'
,
function
(
done
){
var
emitter
=
cli
([
'--stdout'
,
sampleScssPath
]);
emitter
.
on
(
'error'
,
done
);
emitter
.
on
(
'done'
,
function
(){
fs
.
exists
(
sampleCssOutputPath
,
function
(
exists
)
{
assert
(
!
exists
);
if
(
exists
)
{
fs
.
unlinkSync
(
sampleCssOutputPath
);}
done
();
});
});
});
it
(
'should not exit with the --watch option'
,
function
(
done
){
var
command
=
cliPath
+
' --watch '
+
sampleScssPath
;
var
child
=
exec
(
'node '
+
command
);
...
...
@@ -150,15 +164,15 @@ describe('cli', function() {
var
emitter
=
cli
([
sampleScssPath
,
'--source-map'
]);
emitter
.
on
(
'error'
,
done
);
emitter
.
on
(
'write-source-map'
,
function
(
err
,
file
)
{
assert
.
equal
(
file
,
path
.
join
(
__dirname
,
'../sample.css.map'
)
);
assert
.
equal
(
file
,
sampleCssMapOutputPath
);
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
()
{
fs
.
unlink
(
sampleCssMapOutputPath
,
function
()
{
fs
.
unlink
(
sampleCssOutputPath
,
function
()
{
done
();
});
});
...
...
@@ -176,7 +190,7 @@ describe('cli', function() {
});
emitter
.
on
(
'done'
,
function
()
{
fs
.
unlink
(
path
.
join
(
__dirname
,
'../sample.map'
),
function
()
{
fs
.
unlink
(
path
.
join
(
__dirname
,
'../sample.css'
)
,
function
()
{
fs
.
unlink
(
sampleCssOutputPath
,
function
()
{
done
();
});
});
...
...
@@ -187,14 +201,14 @@ describe('cli', function() {
var
emitter
=
cli
([
sampleScssPath
,
'--source-comments'
,
'map'
]);
emitter
.
on
(
'error'
,
done
);
emitter
.
on
(
'write-source-map'
,
function
(
err
,
file
)
{
assert
.
equal
(
file
,
path
.
join
(
__dirname
,
'../sample.css.map'
)
);
assert
.
equal
(
file
,
sampleCssMapOutputPath
);
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
()
{
fs
.
unlink
(
sampleCssMapOutputPath
,
function
()
{
fs
.
unlink
(
sampleCssOutputPath
,
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