dsherret / dsherret/ts-morph

Too slow to move

Open
#953 0 comments 4 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
6.2k
Forks
238
Avg merge
2m
Merged PRs (30d)
1

Description

This operation is too slow. Is there any way to speed it up? thank you.
``` typescript
const pathValue = targetNode.getProperty('path').getFirstChildByKind(ts.SyntaxKind.StringLiteral);
const oldPath = pathValue.getText();
if (oldPath !== itemData.path) {
pathValue.setLiteralValue(itemData.path);

// Modify directory and file names
const dir = project.getDirectory(path.dirname(itemData.component.path));
dir.move(path.join('..', itemData.path)); // <- slow
dir.getSourceFiles().forEach(sourceFile => {
const newFileName = sourceFile.getBaseName().replace(/(.*)\.(.*)\.(.*)/, itemData.path + '.$2.$3');
sourceFile.move(newFileName); // <- slow
});
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.