Skip to content

Commit 508179e

Browse files
Ludovic SCHMIEDERLudovic SCHMIEDER
Ludovic SCHMIEDER
authored and
Ludovic SCHMIEDER
committed
fix: handle service name on multi-lines (strings with '+' operator)
1 parent 5a51fc3 commit 508179e

File tree

1 file changed

+8
-1
lines changed
  • transforms/convert-module-for-to-setup-test

1 file changed

+8
-1
lines changed

transforms/convert-module-for-to-setup-test/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,12 @@ module.exports = function(file, api) {
861861
}
862862
}
863863

864+
function flatten(node) {
865+
const isBE = node.type === 'BinaryExpression';
866+
const isPLUS = node.operator === '+';
867+
return isBE && isPLUS ? [...flatten(node.left), ...flatten(node.right)] : [node];
868+
}
869+
864870
function updateInjectCalls(ctx) {
865871
ctx
866872
.find(j.CallExpression, {
@@ -884,7 +890,8 @@ module.exports = function(file, api) {
884890
let options = p.node.arguments[1];
885891
let as = options.properties.find(property => property.key.name === 'as');
886892
if (as) {
887-
localName = as.value.value;
893+
let flattenValue = flatten(as.value);
894+
localName = flattenValue.map(node => node.value).join('');
888895
}
889896
}
890897
let property = j.identifier(localName);

0 commit comments

Comments
 (0)