spawnSync returns empty string but command runs well in shell directly?

I am finding a way to run shell command in javascript in a synchronous-like way.
The best I currently found is spawnSync but it returns unexpected empty string while the command is correct in shell.

const foo = spawnSync('git', [
  'log',
  '--diff-filter=A',
  '--format="%cI"',
  '--',
  `path/to/a/file/in/repo`,
])
  .stdout.toString() // -> ''

the command runs well in shell however

$ git log --diff-filter=A --format="%cI" -- "path/to/a/file/in/repo"
2023-12-07T22:11:50+08:00