@@ -39,7 +39,11 @@ def rank_manifest_path(dirname, kind):
39
39
40
40
41
41
def find_project_root_and_manifest (project_items ):
42
- """ Given the contents of an archive, find a valid Pebble project.
42
+ """ Given the contents of an archive, find a (potentially) valid Pebble project.
43
+ A potentially valid Pebble project is either:
44
+ - An appinfo.json file next to an 'src/' directory which contains app sources
45
+ - A package.json file which has a 'pebble' key.
46
+ The function chooses the most shallow possible project and prefers package.json to appinfo.json if both are present.
43
47
:param project_items: A list of BaseProjectItems
44
48
:return: A tuple of (path_to_project, manifest BaseProjectItem)
45
49
"""
@@ -62,9 +66,10 @@ def find_project_root_and_manifest(project_items):
62
66
# Choose the most shallow manifest file which has a non-empty source directory.
63
67
sorted_manifests = sorted (found_manifests , key = lambda x : rank_manifest_path (* x [0 ]))
64
68
for (base , kind ), item in sorted_manifests :
65
- src_dir = os .path .join (base , SRC_DIR ) + os .sep
69
+ if kind == "package.json" :
70
+ return os .path .join (base , '' ), item
71
+ src_dir = os .path .join (base , SRC_DIR , '' )
66
72
for src_path in found_src_files :
67
73
if src_path .startswith (src_dir ):
68
- base = base + os .sep if base else ""
69
- return base , item
74
+ return os .path .join (base , '' ), item
70
75
raise InvalidProjectArchiveException (_ ("No project root found." ))
0 commit comments