/
eapostnova
/
2026-1--study--simulation-modeling
Обзор
Документация
Войти
/
eapostnova
/
2026-1--study--simulation-modeling
Код
Запросы
1
Задачи
Вики
Пакеты
0
Релизы
3
CI/CD
Аналитика
Безопасность
develop
node_modules/git-raw-commits/index.js
100 строк
2 KB
Елизавета Постнова
chore(site): add changelog
06 мар 2026, 00:34
Верифицирован
06 мар 2026, 00:34
8cca814
Код
Авторство
О чём код?
'use strict' const dargs = require('dargs') const execFile = require('child_process').execFile const split = require('split2') const { Readable, Transform } = require('stream') const DELIMITER = '------------------------ >8 ------------------------' function normalizeExecOpts (execOpts) { execOpts = execOpts || {} execOpts.cwd = execOpts.cwd || process.cwd() return execOpts } function normalizeGitOpts (gitOpts) { gitOpts = gitOpts || {} gitOpts.format = gitOpts.format || '%B' gitOpts.from = gitOpts.from || '' gitOpts.to = gitOpts.to || 'HEAD' return gitOpts } function getGitArgs (gitOpts) { const gitFormat = `--format=${gitOpts.format || ''}%n${DELIMITER}` const gitFromTo = [gitOpts.from, gitOpts.to].filter(Boolean).join('..') const gitArgs = ['log', gitFormat, gitFromTo] .concat(dargs(gitOpts, { excludes: ['debug', 'from', 'to', 'format', 'path'] })) // allow commits to focus on a single directory // this is useful for monorepos. if (gitOpts.path) { gitArgs.push('--', gitOpts.path) } return gitArgs } function gitRawCommits (rawGitOpts, rawExecOpts) { const readable = new Readable() readable._read = function () {} const gitOpts = normalizeGitOpts(rawGitOpts) const execOpts = normalizeExecOpts(rawExecOpts) const args = getGitArgs(gitOpts) if (gitOpts.debug) { gitOpts.debug('Your git-log command is:\ngit ' + args.join(' ')) } let isError = false const child = execFile('git', args, { cwd: execOpts.cwd, maxBuffer: Infinity }) child.stdout .pipe(split(DELIMITER + '\n')) .pipe( new Transform({ transform (chunk, enc, cb) { readable.push(chunk) isError = false cb() }, flush (cb) { setImmediate(function () { if (!isError) { readable.push(null) readable.emit('close') } cb() }) } }) ) child.stderr .pipe( new Transform({ objectMode: true, highWaterMark: 16, transform (chunk) { isError = true readable.emit('error', new Error(chunk)) readable.emit('close') } }) ) return readable } module.exports = gitRawCommits