Skip to content

Commit

Permalink
node: Use data source for npm cache items...
Browse files Browse the repository at this point in the history
...instead of a python script.
  • Loading branch information
gasinvein authored and refi64 committed Dec 20, 2021
1 parent 53c2cee commit 1fa8efc
Showing 1 changed file with 1 addition and 22 deletions.
23 changes: 1 addition & 22 deletions node/flatpak-node-generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1422,29 +1422,8 @@ def _finalize(self) -> None:
self.gen.add_command(f'FLATPAK_BUILDER_BUILDDIR=$PWD {patch_all_dest}')

if self.index_entries:
# (ab-)use a "script" module to generate the index.
parents: Set[str] = set()

for path in self.index_entries:
for parent in map(str, path.relative_to(self.cacache_dir).parents):
if parent != '.':
parents.add(parent)

index_commands: List[str] = []
index_commands.append('import os')
index_commands.append(f'os.chdir({str(self.cacache_dir)!r})')

for parent in sorted(parents, key=len):
index_commands.append(f'os.makedirs({parent!r}, exist_ok=True)')

for path, entry in self.index_entries.items():
path = path.relative_to(self.cacache_dir)
index_commands.append(f'with open({str(path)!r}, "w") as fp:')
index_commands.append(f' fp.write({entry!r})')

script_dest = self.gen.data_root / 'generate-index.py'
self.gen.add_script_source(index_commands, script_dest)
self.gen.add_command(f'python3 {script_dest}')
self.gen.add_data_source(entry, path)


class YarnLockfileProvider(LockfileProvider):
Expand Down

0 comments on commit 1fa8efc

Please sign in to comment.