summaryrefslogtreecommitdiff
path: root/deps/npm/lib/submodule.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/lib/submodule.js')
-rw-r--r--deps/npm/lib/submodule.js66
1 files changed, 19 insertions, 47 deletions
diff --git a/deps/npm/lib/submodule.js b/deps/npm/lib/submodule.js
index 5ea5a4f463..2231ced9cf 100644
--- a/deps/npm/lib/submodule.js
+++ b/deps/npm/lib/submodule.js
@@ -5,8 +5,8 @@
module.exports = submodule
var npm = require("./npm.js")
- , exec = require("child_process").execFile
, cache = require("./cache.js")
+ , git = require("./utils/git.js")
, asyncMap = require("slide").asyncMap
, chain = require("slide").chain
, which = require("which")
@@ -56,64 +56,36 @@ function submodule_ (pkg, cb) {
}
function updateSubmodule (name, cb) {
- var git = npm.config.get("git")
var args = [ "submodule", "update", "--init", "node_modules/", name ]
- // check for git
- which(git, function (err) {
- if (err) {
- err.code = "ENOGIT"
- return cb(err)
- }
-
- exec(git, args, cb)
- })
+ git.whichAndExec(args, cb)
}
function addSubmodule (name, url, cb) {
- var git = npm.config.get("git")
var args = [ "submodule", "add", url, "node_modules/", name ]
- // check for git
- which(git, function (err) {
- if (err) {
- err.code = "ENOGIT"
- return cb(err)
- }
-
- exec(git, args, function (er) {
- if (er) return cb(er)
- updateSubmodule(name, cb)
- })
- })
+ git.whichAndExec(args, cb)
}
-var getSubmodules = function getSubmodules (cb) {
- var git = npm.config.get("git")
+var getSubmodules = function (cb) {
var args = [ "submodule", "status" ]
- // check for git
- which(git, function (err) {
- if (err) {
- err.code = "ENOGIT"
- return cb(err)
- }
- exec(git, args, function (er, stdout) {
- if (er) return cb(er)
- var res = stdout.trim().split(/\n/).map(function (line) {
- return line.trim().split(/\s+/)[1]
- }).filter(function (line) {
- // only care about submodules in the node_modules folder.
- return line && line.match(/^node_modules\//)
- }).map(function (line) {
- return line.replace(/^node_modules\//g, "")
- })
-
- // memoize.
- getSubmodules = function (cb) { return cb(null, res) }
-
- cb(null, res)
+
+ git.whichAndExec(args, function _(er, stdout) {
+ if (er) return cb(er)
+ var res = stdout.trim().split(/\n/).map(function (line) {
+ return line.trim().split(/\s+/)[1]
+ }).filter(function (line) {
+ // only care about submodules in the node_modules folder.
+ return line && line.match(/^node_modules\//)
+ }).map(function (line) {
+ return line.replace(/^node_modules\//g, "")
})
+
+ // memoize.
+ getSubmodules = function (cb) { return cb(null, res) }
+
+ cb(null, res)
})
}