chore: fix build test

This commit is contained in:
Cheng Liu 2024-08-12 13:43:21 -07:00
parent 7fb2334991
commit 427acc5003
No known key found for this signature in database
GPG key ID: EEC8452F7DB85CD6
2 changed files with 20 additions and 5 deletions

View file

@ -231,17 +231,20 @@ export async function runAsync(runScriptOptions: IRunScriptOptions): Promise<voi
{
kind: 'sparo-command',
name: 'add-partial-completion',
args: prefixArgs.concat(['add', '__fixture__'])
args: prefixArgs.concat(['add', '__fixture__']),
processStdout: replaceBackslashes
},
{
kind: 'sparo-command',
name: 'add-folder-completion',
args: prefixArgs.concat(['add', '__fixture__/'])
args: prefixArgs.concat(['add', '__fixture__/']),
processStdout: replaceBackslashes
},
{
kind: 'sparo-command',
name: 'add-folder-partial-completion',
args: prefixArgs.concat(['add', '__fixture__/dir-a/file'])
args: prefixArgs.concat(['add', '__fixture__/dir-a/file']),
processStdout: replaceBackslashes
},
// branch
// commit
@ -309,3 +312,7 @@ export async function runAsync(runScriptOptions: IRunScriptOptions): Promise<voi
production
});
}
function replaceBackslashes(text: string): string {
return text.replace(/\\/g, '/');
}

View file

@ -27,6 +27,11 @@ export interface ISparoCommandDefinition {
* The working directory
*/
currentWorkingDirectory?: string;
/**
* Process stdout. Use case: Unify path separator to /
*/
processStdout?: (output: string) => string;
}
export interface ICustomCallbackDefinition {
@ -64,7 +69,7 @@ export async function executeCommandsAndCollectOutputs({
const { kind } = commandListDefinition;
switch (commandListDefinition.kind) {
case 'sparo-command': {
const { name, args, currentWorkingDirectory } = commandListDefinition;
const { name, args, currentWorkingDirectory, processStdout } = commandListDefinition;
const subProcess: ChildProcess = Executable.spawn(sparoBinPath, args, {
stdio: 'pipe',
currentWorkingDirectory,
@ -78,8 +83,11 @@ export async function executeCommandsAndCollectOutputs({
let stdout: string = '';
let stderr: string = '';
subProcess.stdout?.on('data', (data: Buffer) => {
const text: string = data.toString();
let text: string = data.toString();
console.log(text);
if (processStdout) {
text = processStdout(text);
}
stdout += text;
});