Bug 1564824 - Format source fails with Prettier on patches with moved files where the original directory also does not exist, r=andi

Differential Revision: https://phabricator.services.mozilla.com/D37537

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Victor Porof 2019-07-10 11:15:18 +00:00
Родитель 3331958c0a
Коммит 9350016346
1 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

@ -1343,10 +1343,15 @@ class StaticAnalysis(MachCommandBase):
prettier = os.path.join(self.topsrcdir, "node_modules", "prettier", "bin-prettier.js")
path = os.path.join(self.topsrcdir, path[0])
# Bug 1564824. Prettier fails on patches with moved files where the
# original directory also does not exist.
assume_dir = os.path.dirname(os.path.join(self.topsrcdir, assume_filename[0]))
assume_filename = assume_filename[0] if os.path.isdir(assume_dir) else path
# We use --stdin-filepath in order to better determine the path for
# the prettier formatter when it is ran outside of the repo, for example
# by the extension hg-formatsource.
args = [binary, prettier, '--stdin-filepath', assume_filename[0]]
args = [binary, prettier, '--stdin-filepath', assume_filename]
process = subprocess.Popen(args, stdin=subprocess.PIPE)
with open(path, 'r') as fin: