v3 new release (#84)

swap to graphql
This commit is contained in:
github-actions[bot]
2022-07-11 13:48:02 -04:00
committed by GitHub
parent 20d2b4f98d
commit e4f3964f67
1492 changed files with 63799 additions and 63001 deletions

View File

@ -69,10 +69,11 @@ function replaceWithMultiple(nodes) {
function replaceWithSourceString(replacement) {
this.resync();
let ast;
try {
replacement = `(${replacement})`;
replacement = (0, _parser.parse)(replacement);
ast = (0, _parser.parse)(replacement);
} catch (err) {
const loc = err.loc;
@ -89,23 +90,21 @@ function replaceWithSourceString(replacement) {
throw err;
}
replacement = replacement.program.body[0].expression;
const expressionAST = ast.program.body[0].expression;
_index.default.removeProperties(replacement);
_index.default.removeProperties(expressionAST);
return this.replaceWith(replacement);
return this.replaceWith(expressionAST);
}
function replaceWith(replacement) {
function replaceWith(replacementPath) {
this.resync();
if (this.removed) {
throw new Error("You can't replace this node, we've already removed it");
}
if (replacement instanceof _index2.default) {
replacement = replacement.node;
}
let replacement = replacementPath instanceof _index2.default ? replacementPath.node : replacementPath;
if (!replacement) {
throw new Error("You passed `path.replaceWith()` a falsy node, use `path.remove()` instead");