Skip to content

Commit

Permalink
chore: fix build test
Browse files Browse the repository at this point in the history
  • Loading branch information
chengcyber committed Aug 12, 2024
1 parent 7fb2334 commit 427acc5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
13 changes: 10 additions & 3 deletions build-tests/sparo-completion-test/src/start-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -309,3 +312,7 @@ export async function runAsync(runScriptOptions: IRunScriptOptions): Promise<voi
production
});
}

function replaceBackslashes(text: string): string {
return text.replace(/\\/g, '/');
}
12 changes: 10 additions & 2 deletions build-tests/test-utilities/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -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;
});

Expand Down

0 comments on commit 427acc5

Please sign in to comment.