Я пишу скрипт пост-фиксации с помощью nodeJS в Windows.Следующий код вызывает последнее сообщение о коммите:
#!/bin/env node
require('child_process').exec('git log -1 --pretty=%B', function(err, commit) {
console.log(commit); // prints message in command prompt with 2 empty lines
var messages = commit.split(' '); // the delimiter is irrelevant
console.log(messages); // prints the array and shows '\n\n' at the end of last element
console.log(messages[messages.length - 1]); // yet this prints the last element WITHOUT '\n\n'
});
Почему появились 2 новые строки?Я читал о том, как Unix и не-Unix системы относятся к CR и LF.Немного о git config core.autocrlf
тоже, но я не думаю, что это проблема.