MCPcopy
hub / github.com/ampproject/amphtml / inquireForWebpage_

Function inquireForWebpage_

build-system/tasks/visual-diff/dev-mode.js:128–156  ·  view source on GitHub ↗

* Queries the user for a webpage, or selects one if only one matched --grep. * * @param {!Array<!WebpageDef>} webpages an array of JSON objects containing * details about the webpages to snapshot. * @return {Promise<!WebpageDef>}

(webpages)

Source from the content-addressed store, hash-verified

126 * @return {Promise<!WebpageDef>}
127 */
128async function inquireForWebpage_(webpages) {
129 if (webpages.length > 1) {
130 return await inquirer.select({
131 message:
132 'Select test name from ' +
133 cyan('visual-diff.jsonc') +
134 ' (use ' +
135 cyan('--grep') +
136 ' to filter this list):',
137 choices: webpages
138 .map((webpage) => ({
139 name: webpage.name,
140 value: webpage,
141 }))
142 .sort((a, b) => a.name.localeCompare(b.name)),
143 });
144 } else {
145 const webpage = webpages[0];
146 log(
147 'info',
148 'Using test',
149 yellow(webpage.name),
150 '(Only one test matches the',
151 cyan('--grep'),
152 'value)'
153 );
154 return webpage;
155 }
156}
157
158/**
159 * Queries the user for an interactive test, or selects the base case if none.

Callers 1

devModeFunction · 0.85

Calls 4

cyanFunction · 0.85
yellowFunction · 0.85
selectMethod · 0.80
logFunction · 0.70

Tested by

no test coverage detected