def validate_elm_make(ctx, param, value):
if value is None:
return value
realpath = os.path.realpath(value)
if not os.path.isfile(realpath):
realpath = shutil.which(value)
if realpath is None or not os.path.isfile(realpath):
raise click.BadParameter('{} not found'.format(value))
elm_make_mimetype = magic.from_file(realpath, mime=True)
if not elm_make_mimetype.startswith('text'):
return value
perhaps_binwrap_of = os.path.normpath(
os.path.join(
os.path.dirname(realpath),
os.pardir,
'elm',
'Elm-Platform',
'*',
'.cabal-sandbox',
'bin',
'elm-make'))
raise click.BadParameter('''should be the real elm-make binary; this looks like a text file.
if you installed Elm through npm, then try {}'''.format(perhaps_binwrap_of))
评论列表
文章目录