fix: increase gh api buffer in repertoire add

This commit is contained in:
nrslib 2026-02-27 00:34:54 +09:00
parent 7e34d5c4c0
commit c9336c03d6

View File

@ -37,21 +37,34 @@ import { createLogger, getErrorMessage } from '../../shared/utils/index.js';
const require = createRequire(import.meta.url); const require = createRequire(import.meta.url);
const { version: TAKT_VERSION } = require('../../../package.json') as { version: string }; const { version: TAKT_VERSION } = require('../../../package.json') as { version: string };
const GH_API_MAX_BUFFER_BYTES = 100 * 1024 * 1024;
const log = createLogger('repertoire-add'); const log = createLogger('repertoire-add');
export async function repertoireAddCommand(spec: string): Promise<void> { export async function repertoireAddCommand(spec: string): Promise<void> {
const { owner, repo, ref: specRef } = parseGithubSpec(spec); const { owner, repo, ref: specRef } = parseGithubSpec(spec);
try { try {
execFileSync('gh', ['--version'], { stdio: 'pipe' }); execFileSync('gh', ['--version'], {
stdio: 'pipe',
maxBuffer: GH_API_MAX_BUFFER_BYTES,
});
} catch { } catch {
throw new Error( throw new Error(
'`gh` CLI がインストールされていません。https://cli.github.com からインストールしてください', '`gh` CLI がインストールされていません。https://cli.github.com からインストールしてください',
); );
} }
const execGh = (args: string[]) => const execGh = (args: string[]) => execFileSync('gh', args, {
execFileSync('gh', args, { encoding: 'utf-8', stdio: 'pipe' }); encoding: 'utf-8',
stdio: 'pipe',
maxBuffer: GH_API_MAX_BUFFER_BYTES,
});
const execGhBinary = (args: string[]) => execFileSync('gh', args, {
stdio: ['pipe', 'pipe', 'pipe'],
maxBuffer: GH_API_MAX_BUFFER_BYTES,
});
const ref = resolveRef(specRef, owner, repo, execGh); const ref = resolveRef(specRef, owner, repo, execGh);
@ -64,14 +77,10 @@ export async function repertoireAddCommand(spec: string): Promise<void> {
mkdirSync(tmpExtractDir, { recursive: true }); mkdirSync(tmpExtractDir, { recursive: true });
info(`📦 ${owner}/${repo} @${ref} をダウンロード中...`); info(`📦 ${owner}/${repo} @${ref} をダウンロード中...`);
const tarballBuffer = execFileSync( const tarballBuffer = execGhBinary([
'gh',
[
'api', 'api',
`/repos/${owner}/${repo}/tarball/${ref}`, `/repos/${owner}/${repo}/tarball/${ref}`,
], ]);
{ stdio: ['pipe', 'pipe', 'pipe'] },
);
writeFileSync(tmpTarPath, tarballBuffer); writeFileSync(tmpTarPath, tarballBuffer);
const tarVerboseList = execFileSync('tar', ['tvzf', tmpTarPath], { const tarVerboseList = execFileSync('tar', ['tvzf', tmpTarPath], {