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
4c72885a
Commit
4c72885a
authored
Feb 10, 2015
by
Adeel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Build: Use node-gyp from dependencies.
Code: Minor refactoring.
parent
fe1d59f5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
40 deletions
+35
-40
extensions.js
lib/extensions.js
+12
-9
index.js
lib/index.js
+5
-9
build.js
scripts/build.js
+10
-12
install.js
scripts/install.js
+8
-10
No files found.
lib/
util
s.js
→
lib/
extension
s.js
View file @
4c72885a
...
@@ -10,19 +10,22 @@ var semver = require('semver'),
...
@@ -10,19 +10,22 @@ var semver = require('semver'),
function
getRuntimeName
()
{
function
getRuntimeName
()
{
return
process
.
execPath
return
process
.
execPath
.
split
(
/
[\\/]
+/
).
pop
()
.
split
(
/
[\\/]
+/
).
pop
()
.
split
(
'.'
)
[
0
]
;
.
split
(
'.'
)
.
shift
()
;
}
}
/**
/**
* Get unique name of binary for current platform
* Get unique name of binary for current platform
*
*
* @api p
ublic
* @api p
rivate
*/
*/
module
.
exports
.
getBinaryIdentifiableName
=
function
()
{
function
getBinaryIdentifiableName
()
{
return
process
.
platform
+
'-'
+
return
[
process
.
platform
,
'-'
,
process
.
arch
+
'-'
+
process
.
arch
,
'-'
,
getRuntimeName
()
+
'-'
+
getRuntimeName
(),
'-'
,
runtimeVersion
.
major
+
'.'
+
runtimeVersion
.
major
,
'.'
,
runtimeVersion
.
minor
;
runtimeVersion
.
minor
].
join
(
''
);
};
}
process
.
runtime
=
getRuntimeName
();
process
.
sassBinaryName
=
getBinaryIdentifiableName
();
lib/index.js
View file @
4c72885a
var
fs
=
require
(
'fs'
),
var
fs
=
require
(
'fs'
),
path
=
require
(
'path'
),
path
=
require
(
'path'
);
utils
=
require
(
'./utils'
);
require
(
'./extensions'
);
/**
/**
* Get binding
* Get binding
...
@@ -12,10 +13,10 @@ function getBinding() {
...
@@ -12,10 +13,10 @@ function getBinding() {
var
candidates
=
[
var
candidates
=
[
path
.
join
(
__dirname
,
'..'
,
'build'
,
'Debug'
,
'binding.node'
),
path
.
join
(
__dirname
,
'..'
,
'build'
,
'Debug'
,
'binding.node'
),
path
.
join
(
__dirname
,
'..'
,
'build'
,
'Release'
,
'binding.node'
),
path
.
join
(
__dirname
,
'..'
,
'build'
,
'Release'
,
'binding.node'
),
path
.
join
(
__dirname
,
'..'
,
'vendor'
,
utils
.
getBinaryIdentifiableName
()
,
'binding.node'
)
path
.
join
(
__dirname
,
'..'
,
'vendor'
,
process
.
sassBinaryName
,
'binding.node'
)
];
];
var
candidate
=
candidates
.
filter
(
fs
.
existsSync
)
[
0
]
;
var
candidate
=
candidates
.
filter
(
fs
.
existsSync
)
.
shift
()
;
if
(
!
candidate
)
{
if
(
!
candidate
)
{
throw
new
Error
(
'`libsass` bindings not found. Try reinstalling `node-sass`?'
);
throw
new
Error
(
'`libsass` bindings not found. Try reinstalling `node-sass`?'
);
...
@@ -146,12 +147,7 @@ function getOptions(options) {
...
@@ -146,12 +147,7 @@ function getOptions(options) {
var
success
=
options
.
success
;
var
success
=
options
.
success
;
options
.
error
=
function
(
err
,
code
)
{
options
.
error
=
function
(
err
,
code
)
{
try
{
err
=
JSON
.
parse
(
err
);
err
=
JSON
.
parse
(
err
);
}
catch
(
e
)
{
err
=
{
message
:
err
};
}
err
.
code
=
code
;
err
.
code
=
code
;
if
(
error
)
{
if
(
error
)
{
...
...
scripts/build.js
View file @
4c72885a
...
@@ -2,8 +2,9 @@ var fs = require('fs'),
...
@@ -2,8 +2,9 @@ var fs = require('fs'),
path
=
require
(
'path'
),
path
=
require
(
'path'
),
spawn
=
require
(
'child_process'
).
spawn
,
spawn
=
require
(
'child_process'
).
spawn
,
mkdir
=
require
(
'mkdirp'
),
mkdir
=
require
(
'mkdirp'
),
Mocha
=
require
(
'mocha'
),
Mocha
=
require
(
'mocha'
);
utils
=
require
(
'../lib/utils'
);
require
(
'../lib/extensions'
);
/**
/**
* After build
* After build
...
@@ -15,9 +16,9 @@ var fs = require('fs'),
...
@@ -15,9 +16,9 @@ var fs = require('fs'),
function
afterBuild
(
options
)
{
function
afterBuild
(
options
)
{
var
folder
=
options
.
debug
?
'Debug'
:
'Release'
;
var
folder
=
options
.
debug
?
'Debug'
:
'Release'
;
var
target
=
path
.
join
(
__dirname
,
'..'
,
'build'
,
folder
,
'binding.node'
);
var
target
=
path
.
join
(
__dirname
,
'..'
,
'build'
,
folder
,
'binding.node'
);
var
install
=
path
.
join
(
__dirname
,
'..'
,
'vendor'
,
options
.
bin
,
'binding.node'
);
var
install
=
path
.
join
(
__dirname
,
'..'
,
'vendor'
,
process
.
sassBinaryName
,
'binding.node'
);
mkdir
(
path
.
join
(
__dirname
,
'..'
,
'vendor'
,
options
.
bin
),
function
(
err
)
{
mkdir
(
path
.
join
(
__dirname
,
'..'
,
'vendor'
,
process
.
sassBinaryName
),
function
(
err
)
{
if
(
err
&&
err
.
code
!==
'EEXIST'
)
{
if
(
err
&&
err
.
code
!==
'EEXIST'
)
{
console
.
error
(
err
.
message
);
console
.
error
(
err
.
message
);
return
;
return
;
...
@@ -49,9 +50,8 @@ function afterBuild(options) {
...
@@ -49,9 +50,8 @@ function afterBuild(options) {
*/
*/
function
build
(
options
)
{
function
build
(
options
)
{
var
bin
=
options
.
platform
===
'win32'
?
'node-gyp.cmd'
:
'node-gyp'
;
var
proc
=
spawn
(
process
.
execPath
,
[
'node_modules/pangyp/bin/node-gyp'
,
'rebuild'
].
concat
(
options
.
args
),
{
var
proc
=
spawn
(
bin
,
[
'rebuild'
].
concat
(
options
.
args
),
{
stdio
:
[
0
,
1
,
2
]
customFds
:
[
0
,
1
,
2
]
});
});
proc
.
on
(
'exit'
,
function
(
code
)
{
proc
.
on
(
'exit'
,
function
(
code
)
{
...
@@ -92,7 +92,7 @@ function parseArgs(args) {
...
@@ -92,7 +92,7 @@ function parseArgs(args) {
return
false
;
return
false
;
}
else
if
(
arg
.
substring
(
0
,
13
)
===
'--target_arch'
)
{
}
else
if
(
arg
.
substring
(
0
,
13
)
===
'--target_arch'
)
{
options
.
arch
=
arg
.
substring
(
14
);
options
.
arch
=
arg
.
substring
(
14
);
}
else
if
(
arg
===
'--debug'
)
{
}
else
if
(
arg
===
'-
d'
||
arg
===
'-
-debug'
)
{
options
.
debug
=
true
;
options
.
debug
=
true
;
}
}
...
@@ -110,18 +110,16 @@ function parseArgs(args) {
...
@@ -110,18 +110,16 @@ function parseArgs(args) {
*/
*/
function
testBinary
(
options
)
{
function
testBinary
(
options
)
{
options
.
bin
=
utils
.
getBinaryIdentifiableName
();
if
(
options
.
force
||
process
.
env
.
SASS_FORCE_BUILD
)
{
if
(
options
.
force
||
process
.
env
.
SASS_FORCE_BUILD
)
{
return
build
(
options
);
return
build
(
options
);
}
}
fs
.
stat
(
path
.
join
(
__dirname
,
'..'
,
'vendor'
,
options
.
bin
,
'binding.node'
),
function
(
err
)
{
fs
.
stat
(
path
.
join
(
__dirname
,
'..'
,
'vendor'
,
process
.
sassBinaryName
,
'binding.node'
),
function
(
err
)
{
if
(
err
)
{
if
(
err
)
{
return
build
(
options
);
return
build
(
options
);
}
}
console
.
log
(
'`'
+
options
.
bin
+
'` exists; testing'
);
console
.
log
(
'`'
+
process
.
sassBinaryName
+
'` exists; testing'
);
var
mocha
=
new
Mocha
({
var
mocha
=
new
Mocha
({
ui
:
'bdd'
,
ui
:
'bdd'
,
...
...
scripts/install.js
View file @
4c72885a
...
@@ -2,8 +2,9 @@ var fs = require('fs'),
...
@@ -2,8 +2,9 @@ var fs = require('fs'),
path
=
require
(
'path'
),
path
=
require
(
'path'
),
request
=
require
(
'request'
),
request
=
require
(
'request'
),
mkdirp
=
require
(
'mkdirp'
),
mkdirp
=
require
(
'mkdirp'
),
exec
=
require
(
'shelljs'
).
exec
,
exec
=
require
(
'shelljs'
).
exec
;
utils
=
require
(
'../lib/utils'
);
require
(
'../lib/extensions'
);
/**
/**
* Download file, if succeeds save, if not delete
* Download file, if succeeds save, if not delete
...
@@ -77,31 +78,28 @@ function applyProxy(options, cb) {
...
@@ -77,31 +78,28 @@ function applyProxy(options, cb) {
*/
*/
function
exists
()
{
function
exists
()
{
var
name
=
utils
.
getBinaryIdentifiableName
();
fs
.
exists
(
path
.
join
(
__dirname
,
'..'
,
'vendor'
,
process
.
sassBinaryName
),
function
(
exists
)
{
fs
.
exists
(
path
.
join
(
__dirname
,
'..'
,
'vendor'
,
name
),
function
(
exists
)
{
if
(
exists
)
{
if
(
exists
)
{
return
;
return
;
}
}
fetch
(
name
);
fetch
();
});
});
}
}
/**
/**
* Fetch binaries
* Fetch binaries
*
*
* @param {String} name
* @api private
* @api private
*/
*/
function
fetch
(
name
)
{
function
fetch
()
{
var
url
=
[
var
url
=
[
'https://raw.githubusercontent.com/sass/node-sass-binaries/v'
,
'https://raw.githubusercontent.com/sass/node-sass-binaries/v'
,
require
(
'../package.json'
).
version
,
'/'
,
n
ame
,
require
(
'../package.json'
).
version
,
'/'
,
process
.
sassBinaryN
ame
,
'/binding.node'
'/binding.node'
].
join
(
''
);
].
join
(
''
);
var
dir
=
path
.
join
(
__dirname
,
'..'
,
'vendor'
,
n
ame
);
var
dir
=
path
.
join
(
__dirname
,
'..'
,
'vendor'
,
process
.
sassBinaryN
ame
);
var
dest
=
path
.
join
(
dir
,
'binding.node'
);
var
dest
=
path
.
join
(
dir
,
'binding.node'
);
mkdirp
(
dir
,
function
(
err
)
{
mkdirp
(
dir
,
function
(
err
)
{
...
...
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