Update checked-in dependencies
This commit is contained in:
parent
4fad06f438
commit
40a500c743
4168 changed files with 298222 additions and 374905 deletions
42
node_modules/execa/lib/command.js
generated
vendored
42
node_modules/execa/lib/command.js
generated
vendored
|
|
@ -76,21 +76,45 @@ const parseExpression = expression => {
|
|||
throw new TypeError(`Unexpected "${typeOfExpression}" in template expression`);
|
||||
};
|
||||
|
||||
const parseTemplate = (template, index, templates, expressions) => {
|
||||
const concatTokens = (tokens, nextTokens, isNew) => isNew || tokens.length === 0 || nextTokens.length === 0
|
||||
? [...tokens, ...nextTokens]
|
||||
: [
|
||||
...tokens.slice(0, -1),
|
||||
`${tokens[tokens.length - 1]}${nextTokens[0]}`,
|
||||
...nextTokens.slice(1),
|
||||
];
|
||||
|
||||
const parseTemplate = ({templates, expressions, tokens, index, template}) => {
|
||||
const templateString = template ?? templates.raw[index];
|
||||
const templateTokens = templateString.split(SPACES_REGEXP).filter(Boolean);
|
||||
const newTokens = concatTokens(
|
||||
tokens,
|
||||
templateTokens,
|
||||
templateString.startsWith(' '),
|
||||
);
|
||||
|
||||
if (index === expressions.length) {
|
||||
return templateTokens;
|
||||
return newTokens;
|
||||
}
|
||||
|
||||
const expression = expressions[index];
|
||||
|
||||
return Array.isArray(expression)
|
||||
? [...templateTokens, ...expression.map(expression => parseExpression(expression))]
|
||||
: [...templateTokens, parseExpression(expression)];
|
||||
const expressionTokens = Array.isArray(expression)
|
||||
? expression.map(expression => parseExpression(expression))
|
||||
: [parseExpression(expression)];
|
||||
return concatTokens(
|
||||
newTokens,
|
||||
expressionTokens,
|
||||
templateString.endsWith(' '),
|
||||
);
|
||||
};
|
||||
|
||||
export const parseTemplates = (templates, expressions) => {
|
||||
let tokens = [];
|
||||
|
||||
for (const [index, template] of templates.entries()) {
|
||||
tokens = parseTemplate({templates, expressions, tokens, index, template});
|
||||
}
|
||||
|
||||
return tokens;
|
||||
};
|
||||
|
||||
export const parseTemplates = (templates, expressions) => templates.flatMap(
|
||||
(template, index) => parseTemplate(template, index, templates, expressions),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue