mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-24 01:38:40 +02:00
flake-modules/new-plugin: find project root
This commit is contained in:
parent
35b6d9bc9d
commit
85b990286d
1 changed files with 17 additions and 2 deletions
|
@ -91,6 +91,18 @@ def write_to_file(file_path, content: str):
|
||||||
f.write(content)
|
f.write(content)
|
||||||
|
|
||||||
|
|
||||||
|
def find_project_root(root_identifier):
|
||||||
|
current_path = os.getcwd()
|
||||||
|
while True:
|
||||||
|
if root_identifier in os.listdir(current_path):
|
||||||
|
return current_path
|
||||||
|
parent_path = os.path.dirname(current_path)
|
||||||
|
if parent_path == current_path:
|
||||||
|
return None
|
||||||
|
os.chdir("..")
|
||||||
|
current_path = os.getcwd()
|
||||||
|
|
||||||
|
|
||||||
# TODO: support interactive unmanaged args
|
# TODO: support interactive unmanaged args
|
||||||
def main():
|
def main():
|
||||||
"""
|
"""
|
||||||
|
@ -109,8 +121,11 @@ def main():
|
||||||
name = kebab_case(args.originalName)
|
name = kebab_case(args.originalName)
|
||||||
|
|
||||||
# Define paths
|
# Define paths
|
||||||
plugin_path = f"plugins/by-name/{name}/default.nix"
|
root_identifier = "flake.nix"
|
||||||
test_path = f"tests/test-sources/plugins/by-name/{name}/default.nix"
|
root_dir = find_project_root(root_identifier)
|
||||||
|
|
||||||
|
plugin_path = f"{root_dir}/plugins/by-name/{name}/default.nix"
|
||||||
|
test_path = f"{root_dir}/tests/test-sources/plugins/by-name/{name}/default.nix"
|
||||||
|
|
||||||
# Create files
|
# Create files
|
||||||
create_nix_file(
|
create_nix_file(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue