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
6d507401
Commit
6d507401
authored
Jun 19, 2014
by
Andrew Nesbitt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #355 from blopker/master
Fix boolean paramaters
parents
40bdc985
7e1f9c58
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
8 deletions
+41
-8
cli.js
lib/cli.js
+4
-2
cli.js
test/cli.js
+37
-6
No files found.
lib/cli.js
View file @
6d507401
...
...
@@ -31,14 +31,16 @@ var optimist = require('optimist')
})
.
options
(
'watch'
,
{
describe
:
'Watch a directory or file'
,
alias
:
'w'
alias
:
'w'
,
type
:
'boolean'
})
.
options
(
'output'
,
{
describe
:
'Output css file'
,
alias
:
'o'
})
.
options
(
'stdout'
,
{
describe
:
'Print the resulting CSS to stdout'
describe
:
'Print the resulting CSS to stdout'
,
type
:
'boolean'
})
.
options
(
'help'
,
{
describe
:
'Print usage info'
,
...
...
test/cli.js
View file @
6d507401
...
...
@@ -27,6 +27,8 @@ var expectedSampleNoComments = '#navbar {\n\
var
expectedSampleCustomImagePath
=
'body {
\
n
\
background-image: url("/path/to/images/image.png"); }
\
n'
;
var
sampleScssPath
=
path
.
join
(
__dirname
,
'sample.scss'
);
describe
(
'cli'
,
function
()
{
it
(
'should print help when run with no arguments'
,
function
(
done
)
{
exec
(
'node '
+
cliPath
,
function
(
err
,
stdout
,
stderr
)
{
...
...
@@ -78,7 +80,7 @@ describe('cli', function() {
});
it
(
'should compile with the --output-style'
,
function
(
done
){
var
emitter
=
cli
([
'--output-style'
,
'compressed'
,
path
.
join
(
__dirname
,
'sample.scss'
)
]);
var
emitter
=
cli
([
'--output-style'
,
'compressed'
,
sampleScssPath
]);
emitter
.
on
(
'error'
,
done
);
emitter
.
on
(
'write'
,
function
(
err
,
file
,
css
){
assert
.
equal
(
css
,
expectedSampleCompressed
);
...
...
@@ -87,7 +89,7 @@ describe('cli', function() {
});
it
(
'should compile with the --source-comments option'
,
function
(
done
){
var
emitter
=
cli
([
'--source-comments'
,
'none'
,
path
.
join
(
__dirname
,
'sample.scss'
)
]);
var
emitter
=
cli
([
'--source-comments'
,
'none'
,
sampleScssPath
]);
emitter
.
on
(
'error'
,
done
);
emitter
.
on
(
'write'
,
function
(
err
,
file
,
css
){
assert
.
equal
(
css
,
expectedSampleNoComments
);
...
...
@@ -106,7 +108,7 @@ describe('cli', function() {
it
(
'should write the output to the file specified with the --output option'
,
function
(
done
){
var
resultPath
=
path
.
join
(
__dirname
,
'../output.css'
);
var
emitter
=
cli
([
'--output'
,
resultPath
,
path
.
join
(
__dirname
,
'sample.scss'
)
]);
var
emitter
=
cli
([
'--output'
,
resultPath
,
sampleScssPath
]);
emitter
.
on
(
'error'
,
done
);
emitter
.
on
(
'write'
,
function
(){
fs
.
exists
(
resultPath
,
function
(
exists
)
{
...
...
@@ -116,8 +118,36 @@ describe('cli', function() {
});
});
it
(
'should write to stdout with the --stdout option'
,
function
(
done
){
var
emitter
=
cli
([
'--stdout'
,
sampleScssPath
]);
emitter
.
on
(
'error'
,
done
);
emitter
.
on
(
'log'
,
function
(
css
){
assert
.
equal
(
css
,
expectedSampleNoComments
);
done
();
});
});
it
(
'should not exit with the --watch option'
,
function
(
done
){
var
command
=
cliPath
+
' --watch '
+
sampleScssPath
;
var
child
=
exec
(
'node '
+
command
);
var
exited
=
false
;
child
.
on
(
'exit'
,
function
()
{
exited
=
true
;
});
setTimeout
(
function
()
{
if
(
exited
){
throw
new
Error
(
'Watch ended too early!'
);
}
else
{
child
.
kill
();
done
();
}
},
100
);
});
it
(
'should compile with the --source-map option'
,
function
(
done
){
var
emitter
=
cli
([
path
.
join
(
__dirname
,
'sample.scss'
)
,
'--source-map'
]);
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'
));
...
...
@@ -125,6 +155,7 @@ describe('cli', function() {
assert
(
exists
);
});
});
emitter
.
on
(
'done'
,
function
()
{
fs
.
unlink
(
path
.
join
(
__dirname
,
'../sample.css.map'
),
function
()
{
fs
.
unlink
(
path
.
join
(
__dirname
,
'../sample.css'
),
function
()
{
...
...
@@ -135,7 +166,7 @@ describe('cli', function() {
});
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'
)]);
var
emitter
=
cli
([
sampleScssPath
,
'--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'
));
...
...
@@ -153,7 +184,7 @@ describe('cli', function() {
});
it
(
'should compile a sourceMap if --source-comments="map", but the --source-map option is excluded'
,
function
(
done
){
var
emitter
=
cli
([
path
.
join
(
__dirname
,
'sample.scss'
)
,
'--source-comments'
,
'map'
]);
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'
));
...
...
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