From dc0db530e1bdd7fc4d02459fbcd83960162cdd60 Mon Sep 17 00:00:00 2001 From: Mo Hyun Date: Tue, 22 Oct 2024 09:00:01 -0700 Subject: [PATCH] Fix invalid flag for `file` on Windows --- dotdrop/templategen.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dotdrop/templategen.py b/dotdrop/templategen.py index 41cd40f..bdb33c9 100644 --- a/dotdrop/templategen.py +++ b/dotdrop/templategen.py @@ -9,6 +9,7 @@ import os import io import re import mmap +import sys from jinja2 import Environment, FileSystemLoader, \ ChoiceLoader, FunctionLoader, TemplateNotFound, \ StrictUndefined @@ -192,7 +193,13 @@ class Templategen: self.log.dbg('using \"magic\" for filetype identification') except ImportError: # fallback - _, filetype = utils.run(['file', '-L', '-b', '--mime-type', src], + + # `file` on Windows doesn't support `-L` + follow_symlink = ['-L'] if sys.platform != 'win32' else [] + + _, filetype = utils.run(['file'] + follow_symlink + ['-b', + '--mime-type', + src], debug=self.debug) self.log.dbg('using \"file\" for filetype identification') filetype = filetype.strip()