grunt watch任务阻止命令行

我是新来的,还在学习,所以我遇到了一个很奇怪的问题。 当我运行"watch"任务时,我的命令行被阻塞,所以基本上我无法做任何事情。 不要忘记,任务是成功完成的。 这是我的命令行输出:

 C:\server\css-test>grunt w Running "watch" task Waiting...OK >> File "compass-examples-master\02\sass\screen.scss" changed. Running "compass" (compass) task unchanged compass-examples-master/02/sass/ie.scss unchanged compass-examples-master/02/sass/print.scss overwrite compass-examples-master/02/stylesheets/new/sass/screen.css Running "watch" task Completed in 1.496s at Fri Mar 22 2013 19:31:37 GMT+0100 (Central Europe Standard Time) - Waiting... 

正如你所看到的,我所做的就是运行"compass"任务,它成功完成。

插入点在Waiting...文本部分后保持闪烁,但键盘input不起作用。

我的咕噜configuration

 module.exports = function (grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), compass: { dist: { options: { sassDir: 'compass-examples-master/02', cssDir: 'compass-examples-master/02/stylesheets/new', imagesDir: 'compas-examples-master/02/images', boring: false, outputStyle: 'nested', require: 'sass-media_query_combiner' } } }, watch: { files: 'compass-examples-master/02/sass/*', tasks: ['c'] } }); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-contrib-compass'); grunt.registerTask('c', 'compass'); grunt.registerTask('w', 'watch'); }; 

我没有使用grunt watch,但是我相信问题在于它是一个持续运行的进程,默认情况下,你的命令行通常一次运行一个进程。 有3种解决scheme可以使用。

  1. 打开一个新的terminal。 你可以一次打开多个,这将允许你使用第二个作为你的主要terminal,而咕噜表占据另一个。
  2. 在命令中使用&符号。 这将开始这个过程,并立即返回给你的命令行,让你用它来做其他事情。 你可以把它想象成在后台运行命令。 该过程仍然连接到terminal窗口,所以如果closures窗口,过程将结束。

    grunt w&

  3. 在你的命令中使用(&)。 这将在后台运行,就像&一样,但是当你closuresterminal窗口时,进程不会被终止。

    (grunt w&)

对于Windows使用

 start grunt 

这将带来一个CMD窗口,它将在后台“监视”,并离开你正在工作的git-bash或cmd窗口。

换句话说,这将在一个单独的cmd窗口中为您运行任务。

只是想让人们知道这个每个评论的工作。

我发现通过同时按Ctrl和c来停止监视过程更简单。 然后,我可以使用命令行然后做东西,然后再运行grunt手表,当我准备回到浏览器。

除了@Nick提出的terminal解决scheme外,还有更好的集成节点解决scheme。

这有一个来自grunt-contib-watch的WONTFIX https://github.com/gruntjs/grunt-contrib-watch/issues/340和grung-bg-shell https://github.com/rma4ok/grunt-bg-shell /问题/ 14 。

build议的select是:

我使用屏幕, https://www.gnu.org/software/screen/ ,所以我可以切换terminal窗口。