melody-compiler
Advanced tools
Comparing version 1.2.0-42f95e8.8 to 1.2.0-70b7860.6
{ | ||
"name": "melody-compiler", | ||
"version": "1.2.0-42f95e8.8+42f95e8", | ||
"version": "1.2.0-70b7860.6+70b7860", | ||
"description": "", | ||
@@ -17,3 +17,3 @@ "main": "./lib/index.js", | ||
"lodash": "^4.12.0", | ||
"melody-code-frame": "1.2.0-42f95e8.8+42f95e8", | ||
"melody-code-frame": "1.2.0-70b7860.6+70b7860", | ||
"random-seed": "^0.3.0" | ||
@@ -29,6 +29,6 @@ }, | ||
"devDependencies": { | ||
"melody-extension-core": "1.2.0-42f95e8.8+42f95e8", | ||
"melody-plugin-idom": "1.2.0-42f95e8.8+42f95e8" | ||
"melody-extension-core": "1.2.0-70b7860.6+70b7860", | ||
"melody-plugin-idom": "1.2.0-70b7860.6+70b7860" | ||
}, | ||
"gitHead": "42f95e8a9d2eb19120722cede9c9b395e4e81c17" | ||
"gitHead": "70b7860e11513e229ac382db686ac565b97a2bac" | ||
} |
@@ -44,52 +44,8 @@ /** | ||
const node = path.node; | ||
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] | ||
) | ||
); | ||
} | ||
path.replaceWithJS({ | ||
type: 'BinaryExpression', | ||
operator: '+', | ||
left: node.left, | ||
right: node.right, | ||
}); | ||
}, | ||
@@ -96,0 +52,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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
178157
3618
3