mirror of
https://github.com/facebook/docusaurus.git
synced 2025-12-26 01:33:02 +00:00
test ...
This commit is contained in:
parent
4f00683b06
commit
bf1720e5bb
|
|
@ -142,31 +142,32 @@ export async function getFileCommitDate(
|
|||
// See why: https://github.com/facebook/docusaurus/pull/10022
|
||||
const resultFormat = includeAuthor ? 'RESULT:%ct,%an' : 'RESULT:%ct';
|
||||
|
||||
const args = [
|
||||
const argsArray = [
|
||||
`--format=${resultFormat}`,
|
||||
'--max-count=1',
|
||||
age === 'oldest' ? '--follow --diff-filter=A' : undefined,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ');
|
||||
].filter((a) => typeof a !== 'undefined');
|
||||
|
||||
const args = argsArray.join(' ');
|
||||
|
||||
const command = `git log ${args} -- "${file}"`;
|
||||
|
||||
const result = (await GitCommandQueue.add(() => {
|
||||
return PerfLogger.async(command, () => {
|
||||
return execa(command, {
|
||||
// shell: true,
|
||||
return execa('git', ['log', ...argsArray, '--', `"${file}"`], {
|
||||
shell: false,
|
||||
});
|
||||
});
|
||||
}))!;
|
||||
|
||||
/*
|
||||
console.log('result', {
|
||||
file,
|
||||
exitCode: result.exitCode,
|
||||
stdout: result.stdout,
|
||||
stderr: result.stderr,
|
||||
result,
|
||||
});
|
||||
|
||||
*/
|
||||
|
||||
if (result.exitCode !== 0) {
|
||||
throw new Error(
|
||||
`Failed to retrieve the git history for file "${file}" with exit code ${result.exitCode}: ${result.stderr}`,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
"profile:bundle:samply": "./profileSamply.sh",
|
||||
"netlify:build:production": "yarn docusaurus write-translations && yarn netlify:crowdin:delay && yarn netlify:crowdin:uploadSources && yarn netlify:crowdin:downloadTranslations && yarn build",
|
||||
"netlify:build:branchDeploy": "yarn build",
|
||||
"netlify:build:deployPreview": "yarn build",
|
||||
"netlify:build:deployPreview": "node test",
|
||||
"netlify:crowdin:delay": "node delayCrowdin.mjs",
|
||||
"netlify:crowdin:wait": "node waitForCrowdin.mjs",
|
||||
"netlify:crowdin:downloadTranslations": "yarn netlify:crowdin:wait && yarn --cwd .. crowdin:download:website",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const execa = require('execa');
|
||||
const {PerfLogger} = require('@docusaurus/logger');
|
||||
|
||||
async function runTest(name, file, options) {
|
||||
for (let i = 0; i < 100; i++) {
|
||||
const before = performance.now();
|
||||
const result = await PerfLogger.async(`${name} ${i}`, async () => {
|
||||
const out = execa.sync(
|
||||
'git',
|
||||
// ['--version'],
|
||||
['log', '--format=RESULT:%ct,%an', '--max-count=1', '--', `"${file}"`],
|
||||
{
|
||||
// stdout: 'inherit',
|
||||
...options,
|
||||
},
|
||||
);
|
||||
|
||||
return out;
|
||||
});
|
||||
|
||||
const time = performance.now() - before;
|
||||
|
||||
// console.log(`${name} ${i} => Time = ${time}`, options, result.exitCode);
|
||||
}
|
||||
}
|
||||
|
||||
async function runAllTests() {
|
||||
await runTest('Shell false', 'website/docs/advanced/architecture.mdx', {
|
||||
shell: false,
|
||||
});
|
||||
|
||||
await runTest('Shell true', 'website/docs/advanced/architecture.mdx', {
|
||||
shell: true,
|
||||
});
|
||||
|
||||
await runTest(
|
||||
'Shell false',
|
||||
'website/i18n/zh-CN/docusaurus-plugin-content-docs/current/advanced/architecture.mdx',
|
||||
{
|
||||
shell: false,
|
||||
},
|
||||
);
|
||||
|
||||
await runTest(
|
||||
'Shell true',
|
||||
'website/i18n/zh-CN/docusaurus-plugin-content-docs/current/advanced/architecture.mdx',
|
||||
{
|
||||
shell: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
runAllTests().then(
|
||||
() => {
|
||||
console.log('success');
|
||||
},
|
||||
(e) => {
|
||||
console.log('failure', e);
|
||||
},
|
||||
);
|
||||
Loading…
Reference in New Issue