我想做的就是通过 Node 执行cmd git submodule -q add -f --depth 1 https://github.com/user/repo node_modules/repo
,但是我似乎无法让它工作。
var cmd = [
'git',
[
'submodule',
'--quiet',
'add',
'--force',
'--depth', '1',
(self.url.replace('git+', '')),
self.installTo
]
]
var git = spawn.apply(spawn, cmd)
git.stderr.on('data', log.error)
git.on('close', function (code, signal) {
// irrelevant because it errors out...
}
我在终端中收到以下错误:
ERR! usage: git submodule [--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>]
or: git submodule [--quiet] status [--cached] [--recursive] [--] [<path>...]
or: git submodule [--quiet] init [--] [<path>...]
or: git submodule [--quiet] deinit [-f|--force] [--] <path>...
or: git submodule [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--reference <repository>] [--recursive] [--] [<path>...]
or: git submodule [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
or: git submodule [--quiet] foreach [--recursive] <command>
or: git submodule [--quiet] sync [--recursive] [--] [<path>...]
最佳答案
使用消息未提及--深度。
这意味着使用的 git 版本不够新,无法包含该选项。
它必须是 1.8.4(2013 年 8 月)之前的 git:该选项是由 commit 275cd18 添加的通过 Fredrik Gustafsson (iveqy
)
关于node.js - 无法通过 Node child_process.spawn 调用 `git submodule add`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33006849/