mirror of
https://github.com/facebook/docusaurus.git
synced 2025-12-26 09:43:10 +00:00
use child_process directly
This commit is contained in:
parent
5b58972094
commit
c44ead96ea
|
|
@ -7,11 +7,29 @@
|
|||
|
||||
import fs from 'fs-extra';
|
||||
import os from 'os';
|
||||
import {exec, type ExecOptions} from 'child_process';
|
||||
import _ from 'lodash';
|
||||
import execa from 'execa';
|
||||
import PQueue from 'p-queue';
|
||||
import {PerfLogger} from '@docusaurus/logger';
|
||||
|
||||
function execPromise(
|
||||
command: string,
|
||||
options: ExecOptions,
|
||||
): Promise<{exitCode: number; stdout: string; stderr: string}> {
|
||||
options.shell = '/bin/bash';
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
exec(command, options, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
resolve({exitCode: 0, stdout, stderr});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Quite high/conservative concurrency value (it was previously "Infinity")
|
||||
// See https://github.com/facebook/docusaurus/pull/10915
|
||||
const DefaultGitCommandConcurrency =
|
||||
|
|
@ -150,18 +168,17 @@ export async function getFileCommitDate(
|
|||
|
||||
const args = argsArray.join(' ');
|
||||
|
||||
const command = `(git ls-files --error-unmatch "${file}" || exit 42) && git log ${args} -- "${file}"`;
|
||||
const command = `git log ${args} -- "${file}"`;
|
||||
|
||||
const result = (await GitCommandQueue.add(() => {
|
||||
return PerfLogger.async(command, () => {
|
||||
return execPromise(command, {});
|
||||
/*
|
||||
return execa(command, {
|
||||
shell: true,
|
||||
}).catch((e) => {
|
||||
if (e.exitCode === 42) {
|
||||
return {exitCode: 0, stdout: '', stderr: ''} as const;
|
||||
}
|
||||
throw e;
|
||||
});
|
||||
|
||||
*/
|
||||
});
|
||||
}))!;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue