1

All I'm trying to do is execute the cmd git submodule -q add -f --depth 1 https://github.com/user/repo node_modules/repo via node, but I can't seem to get it to work.

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...
}

I get the following error in the terminal:

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>...]
caseyWebb
  • 1,997
  • 17
  • 18

1 Answers1

1

The usage message does not mention --depth.

That means the git version used isn't recent enough to include that option.
It must be a git before 1.8.4 (Aug. 2013): that option was added by commit 275cd18 by Fredrik Gustafsson (iveqy)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I'm on git v2.5.3, and if I run it in the shell directly it works. – caseyWebb Oct 08 '15 at 08:16
  • @CaseyWebb sure, but the git used by node seems to be a different one, older. The usage message is telling. – VonC Oct 08 '15 at 08:29
  • I tried again with no additional arguments and get the same error – caseyWebb Oct 09 '15 at 17:09
  • @CaseyWebb can you replace `'--depth', '1',` (which might not be supported anyway) by `'--',`? (and see if that works better?): the double-hyphen helps separating the options from the parameters: http://stackoverflow.com/a/1192194/6309 – VonC Oct 09 '15 at 19:36