Detect more project type.
@@ -15,12 +15,21 @@ def getRootPath(filepath: str, languageId: str) -> str:
rootPath = None
if languageId == "rust":
rootPath = traverseUp(
- filepath,
- lambda folder: os.path.exists(os.path.join(folder, 'Cargo.toml')))
+ filepath, lambda folder:
+ os.path.exists(os.path.join(folder, 'Cargo.toml')))
elif languageId == "php":
rootPath = traverseUp(
- filepath,
- lambda folder: os.path.exists(os.path.join(folder, "composer.json"))) # noqa: E501
+ filepath, lambda folder:
+ os.path.exists(os.path.join(folder, "composer.json")))
+ elif languageId.startswith("javascript") or languageId == "typescript":
+ rootPath = traverseUp(
+ filepath, lambda folder:
+ os.path.exists(os.path.join(folder, "package.json")))
+ elif languageId == "python":
+ rootPath = traverseUp(
+ filepath, lambda folder:
+ os.path.exists(os.path.join(folder, "__init__.py"))
+ or os.path.exists(os.path.join(folder, "setup.py")))
# TODO: detect for other filetypes
if not rootPath:
rootPath = traverseUp(
