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
3733adb2
Commit
3733adb2
authored
Apr 20, 2015
by
xzyfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Init libSass submodule when npm installing via git url
parent
c06ff0f2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
14 deletions
+71
-14
build.js
scripts/build.js
+66
-14
git.sh
scripts/git.sh
+5
-0
No files found.
scripts/build.js
View file @
3733adb2
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
*/
*/
var
eol
=
require
(
'os'
).
EOL
,
var
eol
=
require
(
'os'
).
EOL
,
pkg
=
require
(
'../package.json'
),
fs
=
require
(
'fs'
),
fs
=
require
(
'fs'
),
mkdir
=
require
(
'mkdirp'
),
mkdir
=
require
(
'mkdirp'
),
path
=
require
(
'path'
),
path
=
require
(
'path'
),
...
@@ -46,6 +47,49 @@ function afterBuild(options) {
...
@@ -46,6 +47,49 @@ function afterBuild(options) {
}
}
/**
/**
* initSubmodules
*
* @param {Function} cb
* @api private
*/
function
initSubmodules
(
cb
)
{
var
errorMsg
=
''
;
var
git
=
spawn
([
'LIBSASS_GIT_VERSION='
,
pkg
.
libsass
,
' ./scripts/git.sh'
].
join
());
git
.
stderr
.
on
(
'data'
,
function
(
data
)
{
errorMsg
+=
data
.
toString
();
});
git
.
on
(
'close'
,
function
(
code
)
{
var
error
;
if
(
code
!==
0
)
{
error
=
{
message
:
errorMsg
+
'Unable to checkout the libSass submodule'
};
}
cb
(
error
);
});
}
/**
* installGitDependencies
*
* @param {Function} cb
* @api private
*/
function
installGitDependencies
(
cb
)
{
var
libsassPath
=
'./src/libsass'
;
if
(
fs
.
access
)
{
// node 0.12+, iojs 1.0.0+
fs
.
access
(
libsassPath
,
fs
.
R_OK
,
function
(
err
)
{
err
&&
err
.
code
===
'ENOENT'
?
initSubmodules
(
cb
)
:
cb
();
});
}
else
{
// node < 0.12
fs
.
exists
(
libsassPath
,
function
(
exists
)
{
exists
?
cb
()
:
initSubmodules
(
cb
);
});
}
}
/**
* Build
* Build
*
*
* @param {Object} options
* @param {Object} options
...
@@ -53,25 +97,33 @@ function afterBuild(options) {
...
@@ -53,25 +97,33 @@ function afterBuild(options) {
*/
*/
function
build
(
options
)
{
function
build
(
options
)
{
var
args
=
[
path
.
join
(
'node_modules'
,
'pangyp'
,
'bin'
,
'node-gyp'
),
'rebuild'
].
concat
(
installGitDependencies
(
function
(
err
)
{
[
'libsass_ext'
,
'libsass_cflags'
,
'libsass_ldflags'
,
'libsass_library'
].
map
(
function
(
subject
)
{
if
(
err
)
{
return
[
'--'
,
subject
,
'='
,
process
.
env
[
subject
.
toUpperCase
()]
||
''
].
join
(
''
);
console
.
error
(
err
.
message
);
})).
concat
(
options
.
args
);
process
.
exit
(
1
);
}
console
.
log
([
'Building:'
,
process
.
sass
.
runtime
.
execPath
].
concat
(
args
).
join
(
' '
));
var
args
=
[
path
.
join
(
'node_modules'
,
'pangyp'
,
'bin'
,
'node-gyp'
),
'rebuild'
].
concat
(
[
'libsass_ext'
,
'libsass_cflags'
,
'libsass_ldflags'
,
'libsass_library'
].
map
(
function
(
subject
)
{
return
[
'--'
,
subject
,
'='
,
process
.
env
[
subject
.
toUpperCase
()]
||
''
].
join
(
''
);
})).
concat
(
options
.
args
);
var
proc
=
spawn
(
process
.
sass
.
runtime
.
execPath
,
args
,
{
console
.
log
([
'Building:'
,
process
.
sass
.
runtime
.
execPath
].
concat
(
args
).
join
(
' '
));
stdio
:
[
0
,
1
,
2
]
});
proc
.
on
(
'exit'
,
function
(
errorCode
)
{
var
proc
=
spawn
(
process
.
sass
.
runtime
.
execPath
,
args
,
{
if
(
!
errorCode
)
{
stdio
:
[
0
,
1
,
2
]
afterBuild
(
options
);
}
);
return
;
proc
.
on
(
'exit'
,
function
(
errorCode
)
{
}
if
(
!
errorCode
)
{
afterBuild
(
options
);
console
.
error
(
errorCode
===
127
?
'node-gyp not found!'
:
'Build failed'
);
return
;
}
console
.
error
(
errorCode
===
127
?
'node-gyp not found!'
:
'Build failed'
);
process
.
exit
(
1
);
});
});
});
}
}
...
...
scripts/git.sh
0 → 100755
View file @
3733adb2
#!/bin/sh
git clone
--depth
=
1 git@github.com:sass/libsass.git ./src/libsass
cd
./src/libsass
git checkout
$LIBSASS_GIT_VERSION
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