melody-compiler
Advanced tools
Comparing version 1.2.0-04d171a.4 to 1.2.0-42f95e8.8
{ | ||
"name": "melody-compiler", | ||
"version": "1.2.0-04d171a.4+04d171a", | ||
"version": "1.2.0-42f95e8.8+42f95e8", | ||
"description": "", | ||
@@ -17,3 +17,3 @@ "main": "./lib/index.js", | ||
"lodash": "^4.12.0", | ||
"melody-code-frame": "1.2.0-04d171a.4+04d171a", | ||
"melody-code-frame": "1.2.0-42f95e8.8+42f95e8", | ||
"random-seed": "^0.3.0" | ||
@@ -29,6 +29,6 @@ }, | ||
"devDependencies": { | ||
"melody-extension-core": "1.2.0-04d171a.4+04d171a", | ||
"melody-plugin-idom": "1.2.0-04d171a.4+04d171a" | ||
"melody-extension-core": "1.2.0-42f95e8.8+42f95e8", | ||
"melody-plugin-idom": "1.2.0-42f95e8.8+42f95e8" | ||
}, | ||
"gitHead": "04d171a1547d5dd95966e4a4b416db6cec429bd2" | ||
"gitHead": "42f95e8a9d2eb19120722cede9c9b395e4e81c17" | ||
} |
@@ -44,8 +44,52 @@ /** | ||
const node = path.node; | ||
path.replaceWithJS({ | ||
type: 'BinaryExpression', | ||
operator: '+', | ||
left: node.left, | ||
right: node.right, | ||
}); | ||
if (t.isStringLiteral(node.left)) { | ||
if (t.isStringLiteral(node.right)) { | ||
path.replaceWithJS( | ||
t.stringLiteral(node.left.value + node.right.value) | ||
); | ||
} else { | ||
path.replaceWithJS( | ||
t.templateLiteral( | ||
[t.templateElement({cooked: node.left.value, raw: node.left.value}), t.templateElement({cooked: '', raw: ''})], | ||
[node.right] | ||
) | ||
); | ||
} | ||
} else if (t.isTemplateLiteral(node.left)) { | ||
if (t.isStringLiteral(node.right)) { | ||
// we need to append the new value to the last quasi | ||
// to keep things predictable and pure we start by cloning the existing structure | ||
const quasis = node.left.quasis.map(quasi => t.templateElement({ cooked: quasi.value.cooked, raw: quasi.value.raw })); | ||
const last = quasis[quasis.length - 1]; | ||
last.value.cooked += node.right.value; | ||
last.value.raw += node.right.value; | ||
path.replaceWithJS( | ||
t.templateLiteral( | ||
quasis, | ||
node.left.expressions | ||
) | ||
); | ||
} else { | ||
path.replaceWithJS( | ||
t.templateLiteral( | ||
[...node.left.quasis, t.templateElement({cooked: '', raw: ''})], | ||
[...node.left.expressions, node.right] | ||
) | ||
); | ||
} | ||
} else if (t.isStringLiteral(node.right)) { | ||
path.replaceWithJS( | ||
t.templateLiteral( | ||
[t.templateElement({cooked: '', raw: ''}), t.templateElement({cooked: node.right.value, raw: node.right.value})], | ||
[node.left] | ||
) | ||
); | ||
} else { | ||
path.replaceWithJS( | ||
t.templateLiteral( | ||
[t.templateElement({cooked: '', raw: ''}), t.templateElement({cooked: '', raw: ''}), t.templateElement({cooked: '', raw: ''})], | ||
[node.left, node.right] | ||
) | ||
); | ||
} | ||
}, | ||
@@ -52,0 +96,0 @@ }, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
223491
5135