mirror of
https://github.com/tiktok/sparo.git
synced 2024-11-14 19:35:12 -05:00
chore: fix build test
This commit is contained in:
parent
7fb2334991
commit
427acc5003
2 changed files with 20 additions and 5 deletions
|
@ -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, '/');
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue