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
e6a24f1c
Commit
e6a24f1c
authored
May 12, 2016
by
Nick Schonning
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Chore: Align whitespace to EditorConfig and ESLint
parent
90525f25
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
283 additions
and
283 deletions
+283
-283
node-sass
bin/node-sass
+11
-11
errors.js
lib/errors.js
+1
-1
extensions.js
lib/extensions.js
+12
-12
index.js
lib/index.js
+10
-10
render.js
lib/render.js
+4
-4
build.js
scripts/build.js
+6
-6
coverage.js
scripts/coverage.js
+47
-47
install.js
scripts/install.js
+11
-11
prepublish.js
scripts/prepublish.js
+1
-1
api.js
test/api.js
+11
-11
cli.js
test/cli.js
+33
-33
errors.js
test/errors.js
+2
-2
lowlevel.js
test/lowlevel.js
+8
-8
runtime.js
test/runtime.js
+118
-118
spec.js
test/spec.js
+6
-6
index.js
test/util/index.js
+2
-2
No files found.
bin/node-sass
View file @
e6a24f1c
#!/usr/bin/env node
var
Emitter
=
require
(
'events'
).
EventEmitter
,
forEach
=
require
(
'async-foreach'
).
forEach
,
Gaze
=
require
(
'gaze'
),
grapher
=
require
(
'sass-graph'
),
meow
=
require
(
'meow'
),
util
=
require
(
'util'
),
path
=
require
(
'path'
),
glob
=
require
(
'glob'
),
sass
=
require
(
'../lib'
),
render
=
require
(
'../lib/render'
),
stdin
=
require
(
'get-stdin'
),
fs
=
require
(
'fs'
);
forEach
=
require
(
'async-foreach'
).
forEach
,
Gaze
=
require
(
'gaze'
),
grapher
=
require
(
'sass-graph'
),
meow
=
require
(
'meow'
),
util
=
require
(
'util'
),
path
=
require
(
'path'
),
glob
=
require
(
'glob'
),
sass
=
require
(
'../lib'
),
render
=
require
(
'../lib/render'
),
stdin
=
require
(
'get-stdin'
),
fs
=
require
(
'fs'
);
/**
* Initialize CLI
...
...
lib/errors.js
View file @
e6a24f1c
...
...
@@ -3,7 +3,7 @@
*/
var
sass
=
require
(
'./extensions'
),
pkg
=
require
(
'../package.json'
);
pkg
=
require
(
'../package.json'
);
function
humanEnvironment
()
{
return
sass
.
getHumanEnvironment
(
sass
.
getBinaryName
());
...
...
lib/extensions.js
View file @
e6a24f1c
...
...
@@ -3,10 +3,10 @@
*/
var
eol
=
require
(
'os'
).
EOL
,
fs
=
require
(
'fs'
),
pkg
=
require
(
'../package.json'
),
path
=
require
(
'path'
),
defaultBinaryPath
=
path
.
join
(
__dirname
,
'..'
,
'vendor'
);
fs
=
require
(
'fs'
),
pkg
=
require
(
'../package.json'
),
path
=
require
(
'path'
),
defaultBinaryPath
=
path
.
join
(
__dirname
,
'..'
,
'vendor'
);
/**
* Get the human readable name of the Platform that is running
...
...
@@ -82,10 +82,10 @@ function getHumanNodeVersion(abi) {
*/
function
getHumanEnvironment
(
env
)
{
var
binding
=
env
.
replace
(
/_binding
\.
node$/
,
''
),
parts
=
binding
.
split
(
'-'
),
platform
=
getHumanPlatform
(
parts
[
0
]),
arch
=
getHumanArchitecture
(
parts
[
1
]),
runtime
=
getHumanNodeVersion
(
parts
[
2
]);
parts
=
binding
.
split
(
'-'
),
platform
=
getHumanPlatform
(
parts
[
0
]),
arch
=
getHumanArchitecture
(
parts
[
1
]),
runtime
=
getHumanNodeVersion
(
parts
[
2
]);
if
(
parts
.
length
!==
3
)
{
return
'Unknown environment ('
+
binding
+
')'
;
...
...
@@ -148,7 +148,7 @@ function isSupportedEnvironment(platform, arch, abi) {
function
getArgument
(
name
,
args
)
{
var
flags
=
args
||
process
.
argv
.
slice
(
2
),
index
=
flags
.
lastIndexOf
(
name
);
index
=
flags
.
lastIndexOf
(
name
);
if
(
index
===
-
1
||
index
+
1
>=
flags
.
length
)
{
return
null
;
...
...
@@ -223,7 +223,7 @@ function getBinaryUrl() {
(
pkg
.
nodeSassConfig
&&
pkg
.
nodeSassConfig
.
binarySite
)
||
'https://github.com/sass/node-sass/releases/download'
;
return
[
site
,
'v'
+
pkg
.
version
,
getBinaryName
()].
join
(
'/'
);
return
[
site
,
'v'
+
pkg
.
version
,
getBinaryName
()].
join
(
'/'
);
}
/**
...
...
@@ -277,8 +277,8 @@ function hasBinary(binaryPath) {
function
getVersionInfo
(
binding
)
{
return
[
[
'node-sass'
,
pkg
.
version
,
'(Wrapper)'
,
'[JavaScript]'
].
join
(
'
\
t'
),
[
'libsass '
,
binding
.
libsassVersion
(),
'(Sass Compiler)'
,
'[C/C++]'
].
join
(
'
\
t'
),
[
'node-sass'
,
pkg
.
version
,
'(Wrapper)'
,
'[JavaScript]'
].
join
(
'
\
t'
),
[
'libsass '
,
binding
.
libsassVersion
(),
'(Sass Compiler)'
,
'[C/C++]'
].
join
(
'
\
t'
),
].
join
(
eol
);
}
...
...
lib/index.js
View file @
e6a24f1c
...
...
@@ -3,10 +3,10 @@
*/
var
path
=
require
(
'path'
),
util
=
require
(
'util'
),
clonedeep
=
require
(
'lodash.clonedeep'
),
errors
=
require
(
'./errors'
),
sass
=
require
(
'./extensions'
);
util
=
require
(
'util'
),
clonedeep
=
require
(
'lodash.clonedeep'
),
errors
=
require
(
'./errors'
),
sass
=
require
(
'./extensions'
);
if
(
!
sass
.
hasBinary
(
sass
.
getBinaryPath
()))
{
if
(
!
sass
.
isSupportedEnvironment
())
{
...
...
@@ -239,8 +239,8 @@ function normalizeFunctionSignature(signature, callback) {
signature
:
signature
+
'(...)'
,
callback
:
function
()
{
var
args
=
Array
.
prototype
.
slice
.
call
(
arguments
),
list
=
args
.
shift
(),
i
;
list
=
args
.
shift
(),
i
;
for
(
i
=
list
.
getLength
()
-
1
;
i
>=
0
;
i
--
)
{
args
.
unshift
(
list
.
getValue
(
i
));
...
...
@@ -333,7 +333,7 @@ module.exports.render = function(opts, cb) {
options
.
functions
[
cb
.
signature
]
=
function
()
{
var
args
=
Array
.
prototype
.
slice
.
call
(
arguments
),
bridge
=
args
.
pop
();
bridge
=
args
.
pop
();
function
done
(
data
)
{
bridge
.
success
(
data
);
...
...
@@ -403,11 +403,11 @@ module.exports.renderSync = function(opts) {
var
status
;
if
(
options
.
data
)
{
status
=
binding
.
renderSync
(
options
);
status
=
binding
.
renderSync
(
options
);
}
else
if
(
options
.
file
)
{
status
=
binding
.
renderFileSync
(
options
);
status
=
binding
.
renderFileSync
(
options
);
}
else
{
throw
new
Error
(
'No input specified: provide a file name or a source string to process'
);
throw
new
Error
(
'No input specified: provide a file name or a source string to process'
);
}
var
result
=
options
.
result
;
...
...
lib/render.js
View file @
e6a24f1c
...
...
@@ -3,10 +3,10 @@
*/
var
chalk
=
require
(
'chalk'
),
fs
=
require
(
'fs'
),
mkdirp
=
require
(
'mkdirp'
),
path
=
require
(
'path'
),
sass
=
require
(
'./'
);
fs
=
require
(
'fs'
),
mkdirp
=
require
(
'mkdirp'
),
path
=
require
(
'path'
),
sass
=
require
(
'./'
);
/**
* Render
...
...
scripts/build.js
View file @
e6a24f1c
...
...
@@ -3,12 +3,12 @@
*/
var
eol
=
require
(
'os'
).
EOL
,
pkg
=
require
(
'../package.json'
),
fs
=
require
(
'fs'
),
mkdir
=
require
(
'mkdirp'
),
path
=
require
(
'path'
),
spawn
=
require
(
'cross-spawn'
),
sass
=
require
(
'../lib/extensions'
);
pkg
=
require
(
'../package.json'
),
fs
=
require
(
'fs'
),
mkdir
=
require
(
'mkdirp'
),
path
=
require
(
'path'
),
spawn
=
require
(
'cross-spawn'
),
sass
=
require
(
'../lib/extensions'
);
/**
* After build
...
...
scripts/coverage.js
View file @
e6a24f1c
...
...
@@ -3,52 +3,52 @@
*/
var
Mocha
=
require
(
'mocha'
),
fs
=
require
(
'fs'
),
path
=
require
(
'path'
),
mkdirp
=
require
(
'mkdirp'
),
coveralls
=
require
(
'coveralls'
),
Instrumenter
=
require
(
'istanbul'
).
Instrumenter
,
Report
=
require
(
'istanbul'
).
Report
,
Collector
=
new
require
(
'istanbul'
).
Collector
,
sourcefiles
=
[
'index.js'
,
'extensions.js'
,
'render.js'
,
'errors.js'
],
summary
=
Report
.
create
(
'text-summary'
),
lcov
=
Report
.
create
(
'lcovonly'
,
{
dir
:
path
.
join
(
'coverage'
)
}),
html
=
Report
.
create
(
'html'
,
{
dir
:
path
.
join
(
'coverage'
,
'html'
)
});
fs
=
require
(
'fs'
),
path
=
require
(
'path'
),
mkdirp
=
require
(
'mkdirp'
),
coveralls
=
require
(
'coveralls'
),
Instrumenter
=
require
(
'istanbul'
).
Instrumenter
,
Report
=
require
(
'istanbul'
).
Report
,
Collector
=
new
require
(
'istanbul'
).
Collector
,
sourcefiles
=
[
'index.js'
,
'extensions.js'
,
'render.js'
,
'errors.js'
],
summary
=
Report
.
create
(
'text-summary'
),
lcov
=
Report
.
create
(
'lcovonly'
,
{
dir
:
path
.
join
(
'coverage'
)
}),
html
=
Report
.
create
(
'html'
,
{
dir
:
path
.
join
(
'coverage'
,
'html'
)
});
function
coverage
()
{
var
mocha
=
new
Mocha
();
var
rep
=
function
(
runner
)
{
runner
.
on
(
'end'
,
function
(){
var
cov
=
global
.
__coverage__
,
collector
=
new
Collector
();
if
(
cov
)
{
mkdirp
(
path
.
join
(
'coverage'
,
'html'
),
function
(
err
)
{
if
(
err
)
{
throw
err
;
}
collector
.
add
(
cov
);
summary
.
writeReport
(
collector
,
true
);
html
.
writeReport
(
collector
,
true
);
lcov
.
on
(
'done'
,
function
()
{
fs
.
readFile
(
path
.
join
(
'coverage'
,
'lcov.info'
),
function
(
err
,
data
)
{
if
(
err
)
{
console
.
error
(
err
);
}
coveralls
.
handleInput
(
data
.
toString
(),
var
mocha
=
new
Mocha
();
var
rep
=
function
(
runner
)
{
runner
.
on
(
'end'
,
function
(){
var
cov
=
global
.
__coverage__
,
collector
=
new
Collector
();
if
(
cov
)
{
mkdirp
(
path
.
join
(
'coverage'
,
'html'
),
function
(
err
)
{
if
(
err
)
{
throw
err
;
}
collector
.
add
(
cov
);
summary
.
writeReport
(
collector
,
true
);
html
.
writeReport
(
collector
,
true
);
lcov
.
on
(
'done'
,
function
()
{
fs
.
readFile
(
path
.
join
(
'coverage'
,
'lcov.info'
),
function
(
err
,
data
)
{
if
(
err
)
{
console
.
error
(
err
);
}
coveralls
.
handleInput
(
data
.
toString
(),
function
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
}
});
});
});
lcov
.
writeReport
(
collector
,
true
);
});
}
else
{
console
.
warn
(
'No coverage'
);
}
});
};
var
instrumenter
=
new
Instrumenter
();
var
instrumentedfiles
=
[];
var
processfile
=
function
(
source
)
{
fs
.
readFile
(
path
.
join
(
'lib'
,
source
),
function
(
err
,
data
)
{
if
(
err
)
{
throw
err
;
}
mkdirp
(
'lib-cov'
,
function
(
err
)
{
if
(
err
)
{
throw
err
;
}
fs
.
writeFile
(
path
.
join
(
'lib-cov'
,
source
),
lcov
.
writeReport
(
collector
,
true
);
});
}
else
{
console
.
warn
(
'No coverage'
);
}
});
};
var
instrumenter
=
new
Instrumenter
();
var
instrumentedfiles
=
[];
var
processfile
=
function
(
source
)
{
fs
.
readFile
(
path
.
join
(
'lib'
,
source
),
function
(
err
,
data
)
{
if
(
err
)
{
throw
err
;
}
mkdirp
(
'lib-cov'
,
function
(
err
)
{
if
(
err
)
{
throw
err
;
}
fs
.
writeFile
(
path
.
join
(
'lib-cov'
,
source
),
instrumenter
.
instrumentSync
(
data
.
toString
(),
path
.
join
(
'lib'
,
source
)),
function
(
err
)
{
...
...
@@ -72,12 +72,12 @@ function coverage() {
});
}
});
});
});
};
for
(
var
i
in
sourcefiles
)
{
processfile
(
sourcefiles
[
i
]);
}
});
});
};
for
(
var
i
in
sourcefiles
)
{
processfile
(
sourcefiles
[
i
]);
}
}
/**
...
...
scripts/install.js
View file @
e6a24f1c
...
...
@@ -3,12 +3,12 @@
*/
var
fs
=
require
(
'fs'
),
eol
=
require
(
'os'
).
EOL
,
mkdir
=
require
(
'mkdirp'
),
path
=
require
(
'path'
),
sass
=
require
(
'../lib/extensions'
),
request
=
require
(
'request'
),
pkg
=
require
(
'../package.json'
);
eol
=
require
(
'os'
).
EOL
,
mkdir
=
require
(
'mkdirp'
),
path
=
require
(
'path'
),
sass
=
require
(
'../lib/extensions'
),
request
=
require
(
'request'
),
pkg
=
require
(
'../package.json'
);
/**
* Download file, if succeeds save, if not delete
...
...
@@ -47,15 +47,15 @@ function download(url, dest, cb) {
if
(
err
)
{
reportError
(
err
);
}
else
if
(
!
successful
(
response
))
{
reportError
([
'HTTP error'
,
response
.
statusCode
,
response
.
statusMessage
].
join
(
' '
));
reportError
([
'HTTP error'
,
response
.
statusCode
,
response
.
statusMessage
].
join
(
' '
));
}
else
{
cb
();
cb
();
}
})
.
on
(
'response'
,
function
(
response
)
{
if
(
successful
(
response
))
{
response
.
pipe
(
fs
.
createWriteStream
(
dest
));
}
if
(
successful
(
response
))
{
response
.
pipe
(
fs
.
createWriteStream
(
dest
));
}
});
}
catch
(
err
)
{
cb
(
err
);
...
...
scripts/prepublish.js
View file @
e6a24f1c
...
...
@@ -3,7 +3,7 @@
*/
var
path
=
require
(
'path'
),
rimraf
=
require
(
'rimraf'
);
rimraf
=
require
(
'rimraf'
);
function
prepublish
()
{
var
vendorPath
=
path
.
resolve
(
__dirname
,
'..'
,
'vendor'
);
...
...
test/api.js
View file @
e6a24f1c
var
assert
=
require
(
'assert'
),
fs
=
require
(
'fs'
),
path
=
require
(
'path'
),
read
=
fs
.
readFileSync
,
sassPath
=
process
.
env
.
NODESASS_COV
fs
=
require
(
'fs'
),
path
=
require
(
'path'
),
read
=
fs
.
readFileSync
,
sassPath
=
process
.
env
.
NODESASS_COV
?
require
.
resolve
(
'../lib-cov'
)
:
require
.
resolve
(
'../lib'
),
sass
=
require
(
sassPath
),
fixture
=
path
.
join
.
bind
(
null
,
__dirname
,
'fixtures'
),
resolveFixture
=
path
.
resolve
.
bind
(
null
,
__dirname
,
'fixtures'
);
sass
=
require
(
sassPath
),
fixture
=
path
.
join
.
bind
(
null
,
__dirname
,
'fixtures'
),
resolveFixture
=
path
.
resolve
.
bind
(
null
,
__dirname
,
'fixtures'
);
describe
(
'api'
,
function
()
{
...
...
@@ -233,7 +233,7 @@ describe('api', function() {
contents
:
'@import "b"'
});
}
else
{
console
.
log
(
prev
);
console
.
log
(
prev
);
assert
.
equal
(
prev
,
'/Users/me/sass/lib/a.scss'
);
done
({
file
:
'/Users/me/sass/lib/b.scss'
,
...
...
@@ -1321,7 +1321,7 @@ describe('api', function() {
it
(
'should throw error for bad input'
,
function
(
done
)
{
assert
.
throws
(
function
()
{
sass
.
renderSync
(
'somestring'
);
sass
.
renderSync
(
'somestring'
);
});
assert
.
throws
(
function
()
{
sass
.
renderSync
({
data
:
'#navbar width 80%;'
});
...
...
@@ -1555,7 +1555,7 @@ describe('api', function() {
functions
:
{
'headings($from: 0, $to: 6)'
:
function
(
from
,
to
)
{
var
i
,
f
=
from
.
getValue
(),
t
=
to
.
getValue
(),
list
=
new
sass
.
types
.
List
(
t
-
f
+
1
);
list
=
new
sass
.
types
.
List
(
t
-
f
+
1
);
for
(
i
=
f
;
i
<=
t
;
i
++
)
{
list
.
setValue
(
i
-
f
,
new
sass
.
types
.
String
(
'h'
+
i
));
...
...
@@ -1766,7 +1766,7 @@ describe('api', function() {
describe
(
'.info'
,
function
()
{
var
package
=
require
(
'../package.json'
),
info
=
sass
.
info
;
info
=
sass
.
info
;
it
(
'should return a correct version info'
,
function
(
done
)
{
assert
(
info
.
indexOf
(
package
.
version
)
>
0
);
...
...
test/cli.js
View file @
e6a24f1c
var
assert
=
require
(
'assert'
),
fs
=
require
(
'fs'
),
path
=
require
(
'path'
),
read
=
require
(
'fs'
).
readFileSync
,
glob
=
require
(
'glob'
),
rimraf
=
require
(
'rimraf'
),
stream
=
require
(
'stream'
),
spawn
=
require
(
'cross-spawn'
),
cli
=
path
.
join
(
__dirname
,
'..'
,
'bin'
,
'node-sass'
),
fixture
=
path
.
join
.
bind
(
null
,
__dirname
,
'fixtures'
),
LIBSASS_VERSION
=
null
;
fs
=
require
(
'fs'
),
path
=
require
(
'path'
),
read
=
require
(
'fs'
).
readFileSync
,
glob
=
require
(
'glob'
),
rimraf
=
require
(
'rimraf'
),
stream
=
require
(
'stream'
),
spawn
=
require
(
'cross-spawn'
),
cli
=
path
.
join
(
__dirname
,
'..'
,
'bin'
,
'node-sass'
),
fixture
=
path
.
join
.
bind
(
null
,
__dirname
,
'fixtures'
),
LIBSASS_VERSION
=
null
;
describe
(
'cli'
,
function
()
{
before
(
function
(
done
)
{
var
bin
=
spawn
(
cli
,
[
'-v'
]);
bin
.
stdout
.
setEncoding
(
'utf8'
);
bin
.
stdout
.
once
(
'data'
,
function
(
data
)
{
LIBSASS_VERSION
=
data
.
trim
().
split
([
'
\
n'
])
var
bin
=
spawn
(
cli
,
[
'-v'
]);
bin
.
stdout
.
setEncoding
(
'utf8'
);
bin
.
stdout
.
once
(
'data'
,
function
(
data
)
{
LIBSASS_VERSION
=
data
.
trim
().
split
([
'
\
n'
])
.
filter
(
function
(
a
)
{
return
a
.
substr
(
0
,
7
)
===
'libsass'
;
})[
0
]
.
split
(
'
\
t'
)[
1
];
done
();
});
done
();
});
});
describe
(
'node-sass < in.scss'
,
function
()
{
...
...
@@ -472,23 +472,23 @@ describe('cli', function() {
});
it
(
'should compile with the --source-map-embed option and no outfile'
,
function
(
done
)
{
var
src
=
fixture
(
'source-map-embed/index.scss'
);
var
expectedCss
=
read
(
fixture
(
'source-map-embed/expected.css'
),
'utf8'
).
trim
().
replace
(
/
\r\n
/g
,
'
\
n'
);
var
result
=
''
;
var
bin
=
spawn
(
cli
,
[
src
,
'--source-map-embed'
,
'--source-map'
,
'true'
]);
bin
.
stdout
.
on
(
'data'
,
function
(
data
)
{
result
+=
data
;
});
bin
.
once
(
'close'
,
function
()
{
assert
.
equal
(
result
.
trim
().
replace
(
/
\r\n
/g
,
'
\
n'
),
expectedCss
);
done
();
});
var
src
=
fixture
(
'source-map-embed/index.scss'
);
var
expectedCss
=
read
(
fixture
(
'source-map-embed/expected.css'
),
'utf8'
).
trim
().
replace
(
/
\r\n
/g
,
'
\
n'
);
var
result
=
''
;
var
bin
=
spawn
(
cli
,
[
src
,
'--source-map-embed'
,
'--source-map'
,
'true'
]);
bin
.
stdout
.
on
(
'data'
,
function
(
data
)
{
result
+=
data
;
});
bin
.
once
(
'close'
,
function
()
{
assert
.
equal
(
result
.
trim
().
replace
(
/
\r\n
/g
,
'
\
n'
),
expectedCss
);
done
();
});
});
});
...
...
test/errors.js
View file @
e6a24f1c
var
assert
=
require
(
'assert'
),
path
=
require
(
'path'
),
errors
=
require
(
'../lib/errors'
);
path
=
require
(
'path'
),
errors
=
require
(
'../lib/errors'
);
describe
(
'binary errors'
,
function
()
{
...
...
test/lowlevel.js
View file @
e6a24f1c
process
.
env
.
NODESASS_COV
?
require
(
'../lib-cov'
)
:
require
(
'../lib'
);
var
assert
=
require
(
'assert'
),
sass
=
require
(
'../lib/extensions'
),
binding
=
require
(
sass
.
getBinaryPath
());
sass
=
require
(
'../lib/extensions'
),
binding
=
require
(
sass
.
getBinaryPath
());
describe
(
'lowlevel'
,
function
()
{
it
(
'fail with options not an object'
,
function
(
done
)
{
...
...
@@ -194,8 +194,8 @@ describe('lowlevel', function() {
linefeed
:
'
\
n'
,
result
:
{
stats
:
{}
}
};
binding
.
renderSync
(
options
);
assert
(
options
.
result
.
css
);
binding
.
renderSync
(
options
);
assert
(
options
.
result
.
css
);
done
();
});
...
...
@@ -213,8 +213,8 @@ describe('lowlevel', function() {
linefeed
:
'
\
n'
,
result
:
{
stats
:
{}
}
};
binding
.
renderSync
(
options
);
assert
(
/empty source string/
.
test
(
options
.
result
.
error
),
binding
.
renderSync
(
options
);
assert
(
/empty source string/
.
test
(
options
.
result
.
error
),
'Should fail with error message "Data context created with empty source string"'
);
done
();
});
...
...
@@ -234,8 +234,8 @@ describe('lowlevel', function() {
linefeed
:
'
\
n'
,
result
:
{
stats
:
{}
}
};
binding
.
renderFileSync
(
options
);
assert
(
/empty input path/
.
test
(
options
.
result
.
error
),
binding
.
renderFileSync
(
options
);
assert
(
/empty input path/
.
test
(
options
.
result
.
error
),
'Should fail with error message "File context created with empty input path"'
);
done
();
});
...
...
test/runtime.js
View file @
e6a24f1c
var
assert
=
require
(
'assert'
),
extensionsPath
=
process
.
env
.
NODESASS_COV
extensionsPath
=
process
.
env
.
NODESASS_COV
?
require
.
resolve
(
'../lib-cov/extensions'
)
:
require
.
resolve
(
'../lib/extensions'
);
describe
(
'runtime parameters'
,
function
()
{
var
packagePath
=
require
.
resolve
(
'../package'
),
var
packagePath
=
require
.
resolve
(
'../package'
),
// Let's use JSON to fake a deep copy
savedArgv
=
JSON
.
stringify
(
process
.
argv
),
savedEnv
=
JSON
.
stringify
(
process
.
env
);
savedArgv
=
JSON
.
stringify
(
process
.
argv
),
savedEnv
=
JSON
.
stringify
(
process
.
env
);
beforeEach
(
function
()
{
require
(
packagePath
);
delete
require
.
cache
[
extensionsPath
];
});
afterEach
(
function
()
{
delete
require
.
cache
[
packagePath
];
delete
require
.
cache
[
extensionsPath
];
process
.
argv
=
JSON
.
parse
(
savedArgv
);
process
.
env
=
JSON
.
parse
(
savedEnv
);
require
(
packagePath
);
});
describe
(
'configuration precedence should be respected'
,
function
()
{
describe
(
'SASS_BINARY_NAME'
,
function
()
{
beforeEach
(
function
()
{
process
.
argv
.
push
(
'--sass-binary-name'
,
'aaa'
);
process
.
env
.
SASS_BINARY_NAME
=
'bbb'
;
process
.
env
.
npm_config_sass_binary_name
=
'ccc'
;
require
.
cache
[
packagePath
].
exports
.
nodeSassConfig
=
{
binaryName
:
'ddd'
};
});
it
(
'command line argument'
,
function
()
{
var
sass
=
require
(
extensionsPath
);
assert
.
equal
(
sass
.
getBinaryName
(),
'aaa_binding.node'
);
});
beforeEach
(
function
()
{
require
(
packagePath
);
delete
require
.
cache
[
extensionsPath
];
it
(
'environment variable'
,
function
()
{
process
.
argv
=
[];
var
sass
=
require
(
extensionsPath
);
assert
.
equal
(
sass
.
getBinaryName
(),
'bbb_binding.node'
);
});
it
(
'npm config variable'
,
function
()
{
process
.
argv
=
[];
process
.
env
.
SASS_BINARY_NAME
=
null
;
var
sass
=
require
(
extensionsPath
);
assert
.
equal
(
sass
.
getBinaryName
(),
'ccc_binding.node'
);
});
it
(
'package.json'
,
function
()
{
process
.
argv
=
[];
process
.
env
.
SASS_BINARY_NAME
=
null
;
process
.
env
.
npm_config_sass_binary_name
=
null
;
var
sass
=
require
(
extensionsPath
);
assert
.
equal
(
sass
.
getBinaryName
(),
'ddd_binding.node'
);
});
});
afterEach
(
function
()
{
delete
require
.
cache
[
packagePath
];
delete
require
.
cache
[
extensionsPath
];
process
.
argv
=
JSON
.
parse
(
savedArgv
);
process
.
env
=
JSON
.
parse
(
savedEnv
);
require
(
packagePath
);
describe
(
'SASS_BINARY_SITE'
,
function
()
{
beforeEach
(
function
()
{
process
.
argv
.
push
(
'--sass-binary-site'
,
'http://aaa.example.com:9999'
);
process
.
env
.
SASS_BINARY_SITE
=
'http://bbb.example.com:8888'
;
process
.
env
.
npm_config_sass_binary_site
=
'http://ccc.example.com:7777'
;
require
.
cache
[
packagePath
].
exports
.
nodeSassConfig
=
{
binarySite
:
'http://ddd.example.com:6666'
};
});
it
(
'command line argument'
,
function
()
{
var
sass
=
require
(
extensionsPath
);
var
URL
=
'http://aaa.example.com:9999'
;
assert
.
equal
(
sass
.
getBinaryUrl
().
substr
(
0
,
URL
.
length
),
URL
);
});
it
(
'environment variable'
,
function
()
{
process
.
argv
=
[];
var
sass
=
require
(
extensionsPath
);
var
URL
=
'http://bbb.example.com:8888'
;
assert
.
equal
(
sass
.
getBinaryUrl
().
substr
(
0
,
URL
.
length
),
URL
);
});
it
(
'npm config variable'
,
function
()
{
process
.
argv
=
[];
process
.
env
.
SASS_BINARY_SITE
=
null
;
var
sass
=
require
(
extensionsPath
);
var
URL
=
'http://ccc.example.com:7777'
;
assert
.
equal
(
sass
.
getBinaryUrl
().
substr
(
0
,
URL
.
length
),
URL
);
});
it
(
'package.json'
,
function
()
{
process
.
argv
=
[];
process
.
env
.
SASS_BINARY_SITE
=
null
;
process
.
env
.
npm_config_sass_binary_site
=
null
;
var
sass
=
require
(
extensionsPath
);
var
URL
=
'http://ddd.example.com:6666'
;
assert
.
equal
(
sass
.
getBinaryUrl
().
substr
(
0
,
URL
.
length
),
URL
);
});
});
describe
(
'configuration precedence should be respected'
,
function
()
{
describe
(
'SASS_BINARY_NAME'
,
function
()
{
beforeEach
(
function
()
{
process
.
argv
.
push
(
'--sass-binary-name'
,
'aaa'
);
process
.
env
.
SASS_BINARY_NAME
=
'bbb'
;
process
.
env
.
npm_config_sass_binary_name
=
'ccc'
;
require
.
cache
[
packagePath
].
exports
.
nodeSassConfig
=
{
binaryName
:
'ddd'
};
});
it
(
'command line argument'
,
function
()
{
var
sass
=
require
(
extensionsPath
);
assert
.
equal
(
sass
.
getBinaryName
(),
'aaa_binding.node'
);
});
it
(
'environment variable'
,
function
()
{
process
.
argv
=
[];
var
sass
=
require
(
extensionsPath
);
assert
.
equal
(
sass
.
getBinaryName
(),
'bbb_binding.node'
);
});
it
(
'npm config variable'
,
function
()
{
process
.
argv
=
[];
process
.
env
.
SASS_BINARY_NAME
=
null
;
var
sass
=
require
(
extensionsPath
);
assert
.
equal
(
sass
.
getBinaryName
(),
'ccc_binding.node'
);
});
it
(
'package.json'
,
function
()
{
process
.
argv
=
[];
process
.
env
.
SASS_BINARY_NAME
=
null
;
process
.
env
.
npm_config_sass_binary_name
=
null
;
var
sass
=
require
(
extensionsPath
);
assert
.
equal
(
sass
.
getBinaryName
(),
'ddd_binding.node'
);
});
describe
(
'SASS_BINARY_PATH'
,
function
()
{
beforeEach
(
function
()
{
process
.
argv
.
push
(
'--sass-binary-path'
,
'aaa_binding.node'
);
process
.
env
.
SASS_BINARY_PATH
=
'bbb_binding.node'
;
process
.
env
.
npm_config_sass_binary_path
=
'ccc_binding.node'
;
require
.
cache
[
packagePath
].
exports
.
nodeSassConfig
=
{
binaryPath
:
'ddd_binding.node'
};
});
it
(
'command line argument'
,
function
()
{
var
sass
=
require
(
extensionsPath
);
assert
.
equal
(
sass
.
getBinaryPath
(),
'aaa_binding.node'
);
});
describe
(
'SASS_BINARY_SITE'
,
function
()
{
beforeEach
(
function
()
{
process
.
argv
.
push
(
'--sass-binary-site'
,
'http://aaa.example.com:9999'
);
process
.
env
.
SASS_BINARY_SITE
=
'http://bbb.example.com:8888'
;
process
.
env
.
npm_config_sass_binary_site
=
'http://ccc.example.com:7777'
;
require
.
cache
[
packagePath
].
exports
.
nodeSassConfig
=
{
binarySite
:
'http://ddd.example.com:6666'
};
});
it
(
'command line argument'
,
function
()
{
var
sass
=
require
(
extensionsPath
);
var
URL
=
'http://aaa.example.com:9999'
;
assert
.
equal
(
sass
.
getBinaryUrl
().
substr
(
0
,
URL
.
length
),
URL
);
});
it
(
'environment variable'
,
function
()
{
process
.
argv
=
[];
var
sass
=
require
(
extensionsPath
);
var
URL
=
'http://bbb.example.com:8888'
;
assert
.
equal
(
sass
.
getBinaryUrl
().
substr
(
0
,
URL
.
length
),
URL
);
});
it
(
'npm config variable'
,
function
()
{
process
.
argv
=
[];
process
.
env
.
SASS_BINARY_SITE
=
null
;
var
sass
=
require
(
extensionsPath
);
var
URL
=
'http://ccc.example.com:7777'
;
assert
.
equal
(
sass
.
getBinaryUrl
().
substr
(
0
,
URL
.
length
),
URL
);
});
it
(
'package.json'
,
function
()
{
process
.
argv
=
[];
process
.
env
.
SASS_BINARY_SITE
=
null
;
process
.
env
.
npm_config_sass_binary_site
=
null
;
var
sass
=
require
(
extensionsPath
);
var
URL
=
'http://ddd.example.com:6666'
;
assert
.
equal
(
sass
.
getBinaryUrl
().
substr
(
0
,
URL
.
length
),
URL
);
});
it
(
'environment variable'
,
function
()
{
process
.
argv
=
[];
var
sass
=
require
(
extensionsPath
);
assert
.
equal
(
sass
.
getBinaryPath
(),
'bbb_binding.node'
);
});
describe
(
'SASS_BINARY_PATH'
,
function
()
{
beforeEach
(
function
()
{
process
.
argv
.
push
(
'--sass-binary-path'
,
'aaa_binding.node'
);
process
.
env
.
SASS_BINARY_PATH
=
'bbb_binding.node'
;
process
.
env
.
npm_config_sass_binary_path
=
'ccc_binding.node'
;
require
.
cache
[
packagePath
].
exports
.
nodeSassConfig
=
{
binaryPath
:
'ddd_binding.node'
};
});
it
(
'command line argument'
,
function
()
{
var
sass
=
require
(
extensionsPath
);
assert
.
equal
(
sass
.
getBinaryPath
(),
'aaa_binding.node'
);
});
it
(
'environment variable'
,
function
()
{
process
.
argv
=
[];
var
sass
=
require
(
extensionsPath
);
assert
.
equal
(
sass
.
getBinaryPath
(),
'bbb_binding.node'
);
});
it
(
'npm config variable'
,
function
()
{
process
.
argv
=
[];
process
.
env
.
SASS_BINARY_PATH
=
null
;
var
sass
=
require
(
extensionsPath
);
assert
.
equal
(
sass
.
getBinaryPath
(),
'ccc_binding.node'
);
});
it
(
'package.json'
,
function
()
{
process
.
argv
=
[];
process
.
env
.
SASS_BINARY_PATH
=
null
;
process
.
env
.
npm_config_sass_binary_path
=
null
;
var
sass
=
require
(
extensionsPath
);
assert
.
equal
(
sass
.
getBinaryPath
(),
'ddd_binding.node'
);
});
it
(
'npm config variable'
,
function
()
{
process
.
argv
=
[];
process
.
env
.
SASS_BINARY_PATH
=
null
;
var
sass
=
require
(
extensionsPath
);
assert
.
equal
(
sass
.
getBinaryPath
(),
'ccc_binding.node'
);
});
it
(
'package.json'
,
function
()
{
process
.
argv
=
[];
process
.
env
.
SASS_BINARY_PATH
=
null
;
process
.
env
.
npm_config_sass_binary_path
=
null
;
var
sass
=
require
(
extensionsPath
);
assert
.
equal
(
sass
.
getBinaryPath
(),
'ddd_binding.node'
);
});
});
});
});
// describe('library detection', function() {
...
...
test/spec.js
View file @
e6a24f1c
var
assert
=
require
(
'assert'
),
fs
=
require
(
'fs'
),
exists
=
fs
.
existsSync
,
path
=
require
(
'path'
),
read
=
fs
.
readFileSync
,
sass
=
process
.
env
.
NODESASS_COV
fs
=
require
(
'fs'
),
exists
=
fs
.
existsSync
,
path
=
require
(
'path'
),
read
=
fs
.
readFileSync
,
sass
=
process
.
env
.
NODESASS_COV
?
require
(
'../lib-cov'
)
:
require
(
'../lib'
),
util
=
require
(
'./util'
);
util
=
require
(
'./util'
);
describe
(
'spec'
,
function
()
{
this
.
timeout
(
0
);
...
...
test/util/index.js
View file @
e6a24f1c
var
fs
=
require
(
'fs'
),
join
=
require
(
'path'
).
join
,
spec
=
join
(
__dirname
,
'..'
,
'fixtures'
,
'spec'
,
'spec'
);
join
=
require
(
'path'
).
join
,
spec
=
join
(
__dirname
,
'..'
,
'fixtures'
,
'spec'
,
'spec'
);
/**
* Normalize CSS
...
...
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