问题标签 [grunt-concurrent]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1156 浏览

javascript - 拆分 grunt watch 任务

所以我有5个grunt-contrib-watch任务:

  • sass 编译 sass 文件
  • testConcat 连接测试
  • implementationConcat 连接实现文件以进行测试
  • 预编译车把模板的模板
  • karma 启动 karma 测试运行

我知道grunt watch会看所有的,但我真的需要把它们分成两组——前四个是我的设计师运行静态服务器并做 sass 工作的时候,后两个是我做 js 工作的时候.

grunt-concurrent过去常常将它们分开并同时运行它们,但是虽然这有效,但它似乎有点像黑客。我错过了什么吗?

0 投票
4 回答
3102 浏览

gruntjs - Grunt: `contrib-watch` Fire livereload event after `grunt-nodemon` has restarted when server-side `.coffee` files are compiled

I've been having an issue with Grunt.js and a few plugins, notably: grunt-contrib-watch, grunt-nodemon and grunt-contrib-coffee. I've been trying to figure this out for two days now but I don't think my knowledge of Grunt is sufficient to solve it at this point.

The problem I'm experiencing is simply that I want my server-side .coffee files to compile and then have nodemon restart the server and THEN only have livereload work. Right now, Livereload works as intended for everything but server-side coffee files. contrib-watch detects the change, runs coffee and fires off a livereload event, but then nodemon restarts.

Is there a way to get nodemon to restart before the page reloads so that what I see on the screen is up-to-date with what's going on in my server-side code?

I've been presented with the option of just running nodemon in a separate terminal tab, but I'm on Windows and would much prefer to keep one terminal running for this purpose and is the whole reason I'm using grunt-concurrent.

Here's my Gruntfile, it's quite early in it's stages (as I try to figure all this out). If you would prefer I compile it to JavaScript, then just leave a comment and request so, I will be happy to.

0 投票
1 回答
2211 浏览

gruntjs - Grunt - 使用 grunt-newer 仅对修改过的文件进行 lint

我正在运行一个使用 Concurrent 来运行 Nodemon 和 Watch/Livereload 的 Grunt 任务。在默认加载时,我 lint 并启动 Concurrent。我还想设置一个 Watch 在更改时对单个文件进行 lint。目前,当任何一个文件被更改时,所有文件都会被 lint。

我在 StackOverflow 上检查了一个类似的问题,并决定使用 grunt-newer 作为潜在的解决方案。然而,在我下面的实现中,“较新”前缀似乎没有做任何事情。如何解决此问题,以便仅对更改的文件进行 linted?

0 投票
2 回答
495 浏览

node.js - 同时文件更改后运行一次 grunt-nodemon

这是我的 Gruntfile。我同时运行 nodemon 来运行我的应用程序并观察我的咖啡脚本的变化。

Coffeescript 获取 src 文件并将它们转换为 JS 文件(目前有 3 个,main.coffee、Person.coffee 和 Car.coffee)

我希望我的 Nodemon 在每次这些文件更改时重新启动,以使用最新保存的更改运行它。

问题来了:当只修改了1个 coffee文件时,运行coffee会重新编译所有coffee文件,依次生成3个js文件,依次使nodemon重启3次。这是不可取的,因为我在使用网络请求的应用程序中工作,我不希望它失控。

是否可以让 nodemon 只重启 1 次?

我想连接所有的 JS 文件,但这会弄乱我的 JS 文件的模块化。

我也想过一个接一个地“观看”文件,但如果我达到 50 个文件,那会变得很麻烦。

我怎么解决这个问题?

0 投票
2 回答
3049 浏览

angularjs - 运行 grunt "concurrent:test" 由于警告而中止

我正在使用Yeoman 角度生成器,当我运行此代码时,我会发出咕噜声并发出警告。我在 debian wheezy 中运行,并在运行 grunt 之前运行了这些命令:

gruntfile.js:

警告:

0 投票
1 回答
361 浏览

javascript - Grunt 并发任务会覆盖其他任务的日志记录

我遇到了一个有趣的问题,在任务期间写入终端的某些 grunt 任务似乎在同时运行时会相互覆盖。例如:

我正在尝试同时运行两项任务,一项用于单元测试,一项用于 e2e 测试。两者都应该自动监视我正在处理的文件,因此我的 Gruntfile.js 中有以下内容(这些只是有趣的部分:

Gruntfile.js:

当我从命令行运行“grunt Continuous”时,我看到弹出两个浏览器窗口,正如我所料。通常在第一次运行时,我会从终端获得想要查看的输出:

在 $grunt Continuous 初始运行时:

但是,当我更改(并保存)监视的文件时,我开始看到奇怪的结果。请注意,一遍又一遍地保存同一个文件通常会从并发任务中产生不同的输出:

一遍又一遍地保存相同的文件后:

我相信这里的问题出在日志实际上是如何写入终端的......也就是说,我认为每次运行测试时,grunt 任务都会擦除终端的最后一行并将其替换为当前进度。有什么建议你们都必须控制这种行为,或者以不同的方式设置我的繁重任务以避免问题?

干杯!

0 投票
0 回答
393 浏览

javascript - grunt-concurrent 和处理 SIGINT

我很难理解我在使用 grunt-concurrent 并尝试处理 SIGINT 时看到的行为,并希望有人能对此有所了解。基本上:当我在function(grunt) { }声明中使用 SIGINT 处理程序时,为什么只有一个并发任务会看到 SIGINT?

简要设置:我正在使用 grunt-concurrent 来启动 watch 和 nodemon 任务;我的文件的确切并发节Gruntfile.js是:

我想监视 SIGINT,这样当我点击Ctrl+时C,我可以清理一些作为监视任务的一部分被复制的文件。我首先在函数声明Gruntfile.js之外将以下内容添加到我的末尾:module.exports = function(grunt) { ... }

当它包含在其中并且我点击Ctrl+C时,它运行了 3 次——一次用于我运行的主要 grunt 任务 ( dev),一次用于 grunt-concurrent 运行的两个任务中的每一个 (watchnodemon:dev)。这显然不是我的本意。

当我在方法中移动 SIGINT 处理程序function(grunt) { }时,然后当我点击Ctrl+C时,它只运行一次 - 用于nodemon:dev任务。我无法理解的是为什么我也没有看到它为该watch任务运行(并且对于dev触发它们的主并发任务!),它有点杀了我......主要是因为我不想要当我无法理解它并且不能确定它在这个应用程序最终会出现的所有不同机器上不会相同时,依赖于这种行为。

所以……想法?我在这里想念什么?谢谢!

0 投票
1 回答
1143 浏览

javascript - 用 grunt-concurrent 丑化不工作

我正在尝试使用 grunt-concurrent 并行缩小我的 javascript 文件。我也使用 usemin 和 ngmin。

当我在没有 grunt-concurrent 的情况下使用 uglify 时,我会通过以下日志输出得到预期的结果:

但是当我尝试使用具有该配置的 grunt-concurrent 执行此任务时:

我收到未配置此任务的消息:

我的构建任务配置是这样的:

问题是,如何将 grunt-concurrent 与 uglify 和 usemin/ngmin 结合使用?

0 投票
1 回答
126 浏览

javascript - Unable to Create Jasmine Concurrent Grunt Task

I have set up a bunch of taks that all work but I am having trouble configuring my tests task. I have Jasmine-node up and running and I am able to run my tests from the command line, but I can't seem to get the grunt task working.

GruntFile.js:

#xA;

aliases.yaml: (shortened to show only the test task)

#xA;

test.js

#xA;

Folder Structure:

  • grunt
    • concurrent.js
    • test.js
    • etc
  • GruntFile.js
  • tests
    • sms
      • textReceiver-spec.js

The task loads but it just sits there, and nothing happens. No further information, not even an error. It makes me think it's just not finding my test files? But I've tried linking to a file directly, with the same result.

Result:

ben_cripps$ grunt test

Running "concurrent:test" (concurrent) task

but that's it

0 投票
1 回答
98 浏览

gruntjs - 失败任务上的 Grunt 并发循环

Grunt-Concurrent 有一个有趣的问题。当诸如 Uglify 或 Karma 之类的已注册任务运行无误时,一切都很好。但是如果 Uglification 或 Karma 测试失败,那么 Grunt-Concurrent 将不断循环,直到错误被修复。这对于 Uglify 来说很烦人,但是对于 Karma 单元测试,在修复错误之前很难让它循环。

关于如何解决这个问题的任何想法?

我真的无法提供我们确切设置的示例。

它将继续运行此消息,直到单元测试全部通过:

然后它一次又一次地运行它。