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
5c05acfc
Commit
5c05acfc
authored
Oct 28, 2014
by
Adeel Mujahid
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #486 from pluma/nontty
Don't rely on isTTY for stdin/stdout
parents
5f275e71
99c2d253
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
13 deletions
+67
-13
cli.js
lib/cli.js
+11
-12
cli.js
test/cli.js
+56
-1
No files found.
lib/cli.js
View file @
5c05acfc
...
...
@@ -134,7 +134,7 @@ module.exports = function(args) {
options
.
src
=
input
[
0
]
||
null
;
options
.
dest
=
options
.
output
||
input
[
1
]
||
null
;
if
(
!
options
.
dest
&&
(
process
.
stdout
.
isTTY
||
process
.
env
.
isTTY
)
)
{
if
(
!
options
.
dest
&&
!
options
.
stdout
)
{
var
suffix
=
'.css'
;
if
(
/
\.
css$/
.
test
(
options
.
src
))
{
suffix
=
''
;
...
...
@@ -142,18 +142,17 @@ module.exports = function(args) {
options
.
dest
=
path
.
join
(
cwd
,
path
.
basename
(
options
.
src
,
'.scss'
)
+
suffix
);
}
if
(
process
.
stdin
.
isTTY
||
process
.
env
.
isTTY
)
{
if
(
!
input
.
length
)
{
console
.
error
([
'Provide a sass file to render'
,
''
,
'Example'
,
' node-sass --output-style compressed foobar.scss foobar.css'
,
' cat foobar.scss | node-sass --output-style compressed > foobar.css'
].
join
(
'
\
n'
));
process
.
exit
(
1
);
}
if
(
options
.
src
)
{
run
(
options
,
emitter
);
}
else
if
(
!
input
.
length
&&
(
process
.
stdin
.
isTTY
||
process
.
env
.
isTTY
))
{
console
.
error
([
'Provide a sass file to render'
,
''
,
' Example'
,
' node-sass --output-style compressed foobar.scss foobar.css'
,
' cat foobar.scss | node-sass --output-style compressed > foobar.css'
].
join
(
'
\
n'
));
process
.
exit
(
1
);
}
else
{
stdin
(
function
(
data
)
{
options
.
data
=
data
;
...
...
test/cli.js
View file @
5c05acfc
...
...
@@ -120,6 +120,24 @@ describe('cli', function() {
});
});
it
(
'should compile sample.scss as sample.css without isTTY'
,
function
(
done
)
{
this
.
timeout
(
6000
);
var
env
=
assign
(
process
.
env
,
{
isTTY
:
''
});
var
resultPath
=
path
.
join
(
__dirname
,
'sample.css'
);
exec
(
'node '
+
cliPath
+
' '
+
sampleFilename
,
{
cwd
:
__dirname
,
env
:
env
},
function
(
err
)
{
assert
.
equal
(
err
,
null
);
fs
.
exists
(
resultPath
,
function
(
exists
)
{
assert
(
exists
);
fs
.
unlink
(
resultPath
,
done
);
});
});
});
it
(
'should compile sample.scss to ../out.css'
,
function
(
done
)
{
this
.
timeout
(
6000
);
var
env
=
assign
(
process
.
env
,
{
isTTY
:
true
});
...
...
@@ -204,13 +222,50 @@ describe('cli', function() {
emitter
.
on
(
'error'
,
done
);
emitter
.
on
(
'done'
,
function
()
{
fs
.
exists
(
sampleCssOutputPath
,
function
(
exists
)
{
assert
(
!
exists
);
if
(
exists
)
{
fs
.
unlinkSync
(
sampleCssOutputPath
);}
assert
(
!
exists
);
done
();
});
});
});
it
(
'should write to stdout with the --stdout option without isTTY'
,
function
(
done
)
{
this
.
timeout
(
6000
);
var
env
=
assign
(
process
.
env
,
{
isTTY
:
''
});
exec
(
'node '
+
cliPath
+
' --stdout '
+
sampleScssPath
,
{
cwd
:
__dirname
,
env
:
env
},
function
(
err
,
stdout
)
{
if
(
err
)
{
done
(
err
);
}
else
{
assert
.
equal
(
stdout
.
replace
(
/
[\n\r]
$/
,
''
),
expectedSampleNoComments
);
done
();
}
});
});
it
(
'should not write to disk with the --stdout option without isTTY'
,
function
(
done
)
{
this
.
timeout
(
6000
);
var
env
=
assign
(
process
.
env
,
{
isTTY
:
''
});
exec
(
'node '
+
cliPath
+
' --stdout '
+
sampleScssPath
,
{
cwd
:
__dirname
,
env
:
env
},
function
(
err
)
{
if
(
err
)
{
done
(
err
);
}
else
{
fs
.
exists
(
sampleCssOutputPath
,
function
(
exists
)
{
if
(
exists
)
{
fs
.
unlinkSync
(
sampleCssOutputPath
);}
assert
(
!
exists
);
done
();
});
}
});
});
it
(
'should not exit with the --watch option'
,
function
(
done
)
{
var
command
=
cliPath
+
' --watch '
+
sampleScssPath
;
var
env
=
assign
(
process
.
env
,
{
isTTY
:
true
});
...
...
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