简体   繁体   English

Grunt phpcs警告:使用watch进行文件更改时会生成ENAMETOOLONG

[英]Grunt phpcs Warning: spawn ENAMETOOLONG when use watch for file changes

I recently started to use grunt to help automate some coding tasks. 我最近开始使用grunt来帮助自动化一些编码任务。 I would really like to implement the phpcs (PHP Code Sniffer) module but I'm experiencing errors with trying to get it to work. 我真的很想实现phpcs(PHP代码嗅探器)模块,但是在尝试使其正常工作时遇到了错误。

My dev workstation is a Windows 7 64bit OS. 我的开发工作站是Windows 7 64位操作系统。 I have Node.js installed as well as Grunt and the Grunt CLI. 我安装了Node.js以及Grunt和Grunt CLI。

This is the phpcs config from my grunt file. 这是我grunt文件中的phpcs配置。

    phpcs: {
        theme: {
        src: '**/*.*'
        },
        options: {
            bin: "vendor/bin/phpcs --extensions=php ",
            standard: "WordPress-Core"
        }
    },

    watch: {
        scripts: {
            files: '**/*.js',
            tasks: ['jshint'],
        },
        php: {
            files: '**/*.php',
            tasks: ['phpcs'],
        },
        css: {
            files: '**/*.css',
        },
        lr: {
            options: { 
                livereload: true 
            },
            files: ['**/*.js', '**/*.php', '**/*.css'],
        }
    },

});

When I run grunt and then change a php file I get the following 当我运行grunt然后更改一个php文件时,我得到以下信息

Running "watch" task
Waiting...
>> File "header.php" changed.
Running "phpcs:theme" (phpcs) task
Warning: spawn ENAMETOOLONG Use --force to continue.

Aborted due to warnings.
Completed in 2.422s at Tue May 19 2015 09:57:21 GMT-0400 (Eastern Daylight Time)
 - Waiting...

I've tried to use fenestrate to shorten the paths, but that didn't help. 我尝试使用窗饰来缩短路径,但这无济于事。 I moved my project directory out of my dev wordpress install and closer to the root of my drive, but that didn't help even with fenestrate. 我将项目目录移出了我的dev wordpress安装目录,并移到了驱动器的根目录附近,但这即使有帮助也无济于事。

I'm not sure what path the ENAMETOOLONG warning is complaining about. 我不确定ENAMETOOLONG警告在抱怨什么路径。 I would really like to get this working to help improve my code. 我真的很想让这项工作有助于改善我的代码。

Any suggestions or help would be greatly appreciated. 任何建议或帮助将不胜感激。

I discovered that PHP_CodeSniffer wasn't loading the standards that I had downloaded, as well as the default standards. 我发现PHP_CodeSniffer没有加载我下载的标准以及默认标准。

While trying to load the standards I wanted in, I saw that the path was ending at 在尝试加载我想要的标准时,我发现路径以

c:\program

when it should have been 什么时候应该

c:\program files (x86)\php\v5.6\pear\php\CodeSniffer\Standards

I had originally installed PHP using the Windows Platform Installer. 我最初是使用Windows平台安装程序安装PHP的。 So I ended up removing my PHP install. 所以我最终删除了我的PHP安装。 Downloaded PHP 5.6 again and unzipping to a folder off of the root of C: and then re-installed pear and re-installed PHP_CodeSniffer and now it's working in my grunt file. 再次下载PHP 5.6,并解压缩到C:根目录下的文件夹,然后重新安装pear和重新安装PHP_CodeSniffer,现在它可以在我的grunt文件中工作了。 It's processing all of my PHP files and not just the one that changes, but it's at least working. 它正在处理我的所有PHP文件,而不仅仅是处理已更改的文件,但它至少可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM