mirror of
				https://github.com/docker/setup-buildx-action.git
				synced 2025-11-04 06:34:19 +08:00 
			
		
		
		
	Merge pull request #20 from crazy-max/exclude-empty-items
Exclude empty items from input list
This commit is contained in:
		
						commit
						1f6a4febac
					
				@ -15,6 +15,13 @@ describe('getInputList', () => {
 | 
				
			|||||||
    expect(res).toEqual(['bar', 'baz']);
 | 
					    expect(res).toEqual(['bar', 'baz']);
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  it('remove empty lines correctly', async () => {
 | 
				
			||||||
 | 
					    setInput('foo', 'bar\n\nbaz');
 | 
				
			||||||
 | 
					    const res = await context.getInputList('foo');
 | 
				
			||||||
 | 
					    console.log(res);
 | 
				
			||||||
 | 
					    expect(res).toEqual(['bar', 'baz']);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  it('handles comma correctly', async () => {
 | 
					  it('handles comma correctly', async () => {
 | 
				
			||||||
    setInput('foo', 'bar,baz');
 | 
					    setInput('foo', 'bar,baz');
 | 
				
			||||||
    const res = await context.getInputList('foo');
 | 
					    const res = await context.getInputList('foo');
 | 
				
			||||||
@ -22,6 +29,13 @@ describe('getInputList', () => {
 | 
				
			|||||||
    expect(res).toEqual(['bar', 'baz']);
 | 
					    expect(res).toEqual(['bar', 'baz']);
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  it('remove empty result correctly', async () => {
 | 
				
			||||||
 | 
					    setInput('foo', 'bar,baz,');
 | 
				
			||||||
 | 
					    const res = await context.getInputList('foo');
 | 
				
			||||||
 | 
					    console.log(res);
 | 
				
			||||||
 | 
					    expect(res).toEqual(['bar', 'baz']);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  it('handles different new lines correctly', async () => {
 | 
					  it('handles different new lines correctly', async () => {
 | 
				
			||||||
    setInput('foo', 'bar\r\nbaz');
 | 
					    setInput('foo', 'bar\r\nbaz');
 | 
				
			||||||
    const res = await context.getInputList('foo');
 | 
					    const res = await context.getInputList('foo');
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										3
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							@ -6594,7 +6594,8 @@ function getInputList(name, ignoreComma) {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        return items
 | 
					        return items
 | 
				
			||||||
            .split(/\r?\n/)
 | 
					            .split(/\r?\n/)
 | 
				
			||||||
            .reduce((acc, line) => acc.concat(!ignoreComma ? line.split(',') : line).map(pat => pat.trim()), []);
 | 
					            .filter(x => x)
 | 
				
			||||||
 | 
					            .reduce((acc, line) => acc.concat(!ignoreComma ? line.split(',').filter(x => x) : line).map(pat => pat.trim()), []);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
exports.getInputList = getInputList;
 | 
					exports.getInputList = getInputList;
 | 
				
			||||||
 | 
				
			|||||||
@ -35,7 +35,11 @@ export async function getInputList(name: string, ignoreComma?: boolean): Promise
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  return items
 | 
					  return items
 | 
				
			||||||
    .split(/\r?\n/)
 | 
					    .split(/\r?\n/)
 | 
				
			||||||
    .reduce<string[]>((acc, line) => acc.concat(!ignoreComma ? line.split(',') : line).map(pat => pat.trim()), []);
 | 
					    .filter(x => x)
 | 
				
			||||||
 | 
					    .reduce<string[]>(
 | 
				
			||||||
 | 
					      (acc, line) => acc.concat(!ignoreComma ? line.split(',').filter(x => x) : line).map(pat => pat.trim()),
 | 
				
			||||||
 | 
					      []
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const asyncForEach = async (array, callback) => {
 | 
					export const asyncForEach = async (array, callback) => {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user