Skip to content

Commit

Permalink
feat: rename template as well while renaming component file
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Jan 3, 2019
1 parent e65424a commit dd85bc2
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/methods/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,30 @@ export default function(
const componentFile = hub.filename;
const templateFile = hub.options.templateFile;
const newFile = getNewComponentPath(componentFile, templateFile, type);
const wasEntryPoint = type === "defineComponent";
const newTemplateFile = componentFile.replace(/\.[^.]+$/, ".marko");

if (wasEntryPoint) {
await helper.run("updateFilePath", {
from: templateFile,
to: newTemplateFile
});

await helper.run("updateDependentPaths", {
from: templateFile,
to: newTemplateFile
});
}

await helper.run("updateFilePath", {
from: componentFile,
to: newFile
});

if (type !== "defineComponent") {
await helper.run("updateDependentPaths", {
from: componentFile,
to: newFile
});
}
await helper.run("updateDependentPaths", {
from: componentFile,
to: wasEntryPoint ? newTemplateFile : newFile
});
}
});
}
Expand Down

0 comments on commit dd85bc2

Please sign in to comment.