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
1ed5ce94
Commit
1ed5ce94
authored
Oct 21, 2017
by
Kristaps Austers
Committed by
Michael Mifsud
Mar 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow setting of SASS_BINARY_DIR without setting explicit binary name
parent
b926705b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
3 deletions
+67
-3
extensions.js
lib/extensions.js
+36
-3
runtime.js
test/runtime.js
+31
-0
No files found.
lib/extensions.js
View file @
1ed5ce94
...
@@ -7,7 +7,7 @@ var eol = require('os').EOL,
...
@@ -7,7 +7,7 @@ var eol = require('os').EOL,
pkg
=
require
(
'../package.json'
),
pkg
=
require
(
'../package.json'
),
mkdir
=
require
(
'mkdirp'
),
mkdir
=
require
(
'mkdirp'
),
path
=
require
(
'path'
),
path
=
require
(
'path'
),
defaultBinary
Path
=
path
.
join
(
__dirname
,
'..'
,
'vendor'
),
defaultBinary
Dir
=
path
.
join
(
__dirname
,
'..'
,
'vendor'
),
trueCasePathSync
=
require
(
'true-case-path'
);
trueCasePathSync
=
require
(
'true-case-path'
);
/**
/**
...
@@ -126,7 +126,7 @@ function getHumanEnvironment(env) {
...
@@ -126,7 +126,7 @@ function getHumanEnvironment(env) {
* @api public
* @api public
*/
*/
function
getInstalledBinaries
()
{
function
getInstalledBinaries
()
{
return
fs
.
readdirSync
(
defaultBinaryPath
);
return
fs
.
readdirSync
(
getBinaryDir
()
);
}
}
/**
/**
...
@@ -246,6 +246,38 @@ function getBinaryUrl() {
...
@@ -246,6 +246,38 @@ function getBinaryUrl() {
}
}
/**
/**
* Get binary dir.
* If environment variable SASS_BINARY_DIR,
* .npmrc variable sass_binary_dir or
* process argument --sass-binary-dir is provided,
* select it by appending binary name, otherwise
* use default binary dir.
* Once the primary selection is made, check if
* callers wants to throw if file not exists before
* returning.
*
* @api public
*/
function
getBinaryDir
()
{
var
binaryDir
;
if
(
getArgument
(
'--sass-binary-dir'
))
{
binaryDir
=
getArgument
(
'--sass-binary-dir'
);
}
else
if
(
process
.
env
.
SASS_BINARY_DIR
)
{
binaryDir
=
process
.
env
.
SASS_BINARY_DIR
;
}
else
if
(
process
.
env
.
npm_config_sass_binary_dir
)
{
binaryDir
=
process
.
env
.
npm_config_sass_binary_dir
;
}
else
if
(
pkg
.
nodeSassConfig
&&
pkg
.
nodeSassConfig
.
binaryDir
)
{
binaryDir
=
pkg
.
nodeSassConfig
.
binaryDir
;
}
else
{
binaryDir
=
defaultBinaryDir
;
}
return
binaryDir
;
}
/**
* Get binary path.
* Get binary path.
* If environment variable SASS_BINARY_PATH,
* If environment variable SASS_BINARY_PATH,
* .npmrc variable sass_binary_path or
* .npmrc variable sass_binary_path or
...
@@ -271,7 +303,7 @@ function getBinaryPath() {
...
@@ -271,7 +303,7 @@ function getBinaryPath() {
}
else
if
(
pkg
.
nodeSassConfig
&&
pkg
.
nodeSassConfig
.
binaryPath
)
{
}
else
if
(
pkg
.
nodeSassConfig
&&
pkg
.
nodeSassConfig
.
binaryPath
)
{
binaryPath
=
pkg
.
nodeSassConfig
.
binaryPath
;
binaryPath
=
pkg
.
nodeSassConfig
.
binaryPath
;
}
else
{
}
else
{
binaryPath
=
path
.
join
(
defaultBinaryPath
,
getBinaryName
().
replace
(
/_
(?=
binding
\.
node
)
/
,
'/'
));
binaryPath
=
path
.
join
(
getBinaryDir
()
,
getBinaryName
().
replace
(
/_
(?=
binding
\.
node
)
/
,
'/'
));
}
}
if
(
process
.
versions
.
modules
<
46
)
{
if
(
process
.
versions
.
modules
<
46
)
{
...
@@ -415,6 +447,7 @@ function getPlatformVariant() {
...
@@ -415,6 +447,7 @@ function getPlatformVariant() {
module
.
exports
.
hasBinary
=
hasBinary
;
module
.
exports
.
hasBinary
=
hasBinary
;
module
.
exports
.
getBinaryUrl
=
getBinaryUrl
;
module
.
exports
.
getBinaryUrl
=
getBinaryUrl
;
module
.
exports
.
getBinaryName
=
getBinaryName
;
module
.
exports
.
getBinaryName
=
getBinaryName
;
module
.
exports
.
getBinaryDir
=
getBinaryDir
;
module
.
exports
.
getBinaryPath
=
getBinaryPath
;
module
.
exports
.
getBinaryPath
=
getBinaryPath
;
module
.
exports
.
getBinaryCachePath
=
getBinaryCachePath
;
module
.
exports
.
getBinaryCachePath
=
getBinaryCachePath
;
module
.
exports
.
getCachedBinary
=
getCachedBinary
;
module
.
exports
.
getCachedBinary
=
getCachedBinary
;
...
...
test/runtime.js
View file @
1ed5ce94
...
@@ -83,6 +83,37 @@ describe('runtime parameters', function() {
...
@@ -83,6 +83,37 @@ describe('runtime parameters', function() {
});
});
});
});
describe
(
'SASS_BINARY_DIR'
,
function
()
{
beforeEach
(
function
()
{
process
.
argv
.
push
(
'--sass-binary-dir'
,
'aaa'
);
process
.
env
.
SASS_BINARY_DIR
=
'bbb'
;
process
.
env
.
npm_config_sass_binary_dir
=
'ccc'
;
pkg
.
nodeSassConfig
=
{
binaryDir
:
'ddd'
};
});
it
(
'command line argument'
,
function
()
{
assert
.
equal
(
sass
.
getBinaryDir
(),
'aaa'
);
});
it
(
'environment variable'
,
function
()
{
process
.
argv
=
[];
assert
.
equal
(
sass
.
getBinaryDir
(),
'bbb'
);
});
it
(
'npm config variable'
,
function
()
{
process
.
argv
=
[];
process
.
env
.
SASS_BINARY_DIR
=
null
;
assert
.
equal
(
sass
.
getBinaryDir
(),
'ccc'
);
});
it
(
'package.json'
,
function
()
{
process
.
argv
=
[];
process
.
env
.
SASS_BINARY_DIR
=
null
;
process
.
env
.
npm_config_sass_binary_dir
=
null
;
assert
.
equal
(
sass
.
getBinaryDir
(),
'ddd'
);
});
});
describe
(
'SASS_BINARY_PATH'
,
function
()
{
describe
(
'SASS_BINARY_PATH'
,
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
process
.
argv
.
push
(
'--sass-binary-path'
,
'aaa_binding.node'
);
process
.
argv
.
push
(
'--sass-binary-path'
,
'aaa_binding.node'
);
...
...
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