运行 来自 Cygwin 的 Nodejs 的 Lessc 抛出绝对路径错误

Running Nodejs' Lessc from Cygwin throws error with absolute path

我通过 Windows 安装程序安装了 Windows 10(64 位)、Cygwin、Nodejs,并在 Nodejs 之上安装了 lessc

我正在尝试 django-compressor 按照文档中的建议使用预编译器:

COMPRESS_PRECOMPILERS = (
    #...
    ('text/less', 'lessc {infile} {outfile}'),
    #...
)

它抛出

lessc: ENOENT: no such file or directory, open 'C:\awkwardly\converted\cygwin\path\to\my\file.less'(注意添加的盘符)

我从 Cygwin 控制台测试了命令 lessc。只要我使用相对路径,它就可以正常工作,但是当我使用绝对路径时,它会将其转换为 Windows 路径,甚至在前面加上一个驱动器号,例如

C:\cygdrive\d\projects\my\path\to\file.less

我怎么能fix/workaround这个?

到目前为止,该选项正在使用 cygpathlessc 提供适当的 windows 路径,如下所示:

COMPRESS_PRECOMPILERS = (
    #...
    ('text/less', 'lessc $(cygpath -w {infile}) > {outfile}'),
    #...
)

此外,输出必须重定向到 {outfile},而不是将 {outfile} 作为参数传递。