Tag: gruntjs

如何通过grunt-nodemon重新启动node.js服务器时输出时间戳?

我有简单的hello world nodejs express应用程序,我只是添加了grunt-nodemon,它应该监视* .js文件上的更改。 这里是我运行grunt然后更改一些.js文件时得到的控制台输出: Running "nodemon:dev" (nodemon) task [nodemon] v1.3.7 [nodemon] to restart at any time, enter `rs` [nodemon] watching: *.* [nodemon] starting `node server.js` Example app listening at http://:::3000 [nodemon] restarting due to changes… [nodemon] starting `node server.js` Example app listening at http://:::3000 有没有办法在控制台日志中看到每个这些行的前置时间戳? 例如。 18:44:21 – Running "nodemon:dev" (nodemon) task 18:44:21 […]

Grunt在任务执行之间执行自定义脚本

是否有可能做一个咕task任务以下内容? grunt.registerTask('build', 'Building app', function () { grunt.task.run([ 'clean:dist', 'wiredep', 'useminPrepare', 'ngtemplates', 'concat:generated', 'ngAnnotate', 'copy:dist', 'cdnify', 'cssmin' ]); // Replace "vendor-*.js" references to "vendor.js" require('./custom_modules/changeref/changeref')(grunt, this.async, { filePath: './dist/*.html', find: /(vendor-).*\.js/ig, replaceBy: 'vendor.js' }); grunt.task.run([ 'uglify', 'filerev', 'usemin', 'htmlmin' ]); }); 基本上,我需要一个具有加载一些.html文件的function的节点模块,并replace它们中的一些引用。 这个想法是能够在两组任务之间做到这一点。 我已经testing了它,似乎我的自定义函数在执行grunt任务之前被执行。 这是changeref.js模块: 'use strict'; var path = require('path'); module.exports = function(grunt, async, […]

build立一些文件,其余的复制

我有一个非常简单的项目。 我有一些bash文件和src/目录中的一些JavaScript文件,我想要传输JS文件,并复制其余的。 这是我的文件夹结构: root |- dist // Where grunt should output |- src | |- run_code // this is a bash file calling `code` | |- code.es6 // My JavaScript files | |- Gruntfile.js |- package.json 所以目前我有一个叫做babel的Gruntfile,它把我的.es6文件转换成.js ,但不幸的是,我的bash文件run_code没有被转发。 这是我的gruntfile: module.exports = function(grunt) { require('load-grunt-tasks')(grunt); grunt.initConfig({ babel: { options: { presets: ['es2015'], plugins: [] }, dist: […]

不能安装grunt-cli,但可以安装凉亭

我有一个没有身份validation代理后面的Linux框。 我已经configurationgit使用https而不是git。 url.https://.insteadof=git:// 我已经设置了我的http_proxy和https_proxy环境variables以及npm代理。 ; cli configs user-agent = "npm/3.8.6 node/v6.0.0 linux x64" ; userconfig /jenkins/.npmrc https-proxy = "{host}:8060" proxy = "{host}:8060" 我可以安装凉亭: npm install -g bower 但是当我尝试 npm install -g grunt-cli 我得到: npm ERR! fetch failed https://registry.npmjs.org/grunt-cli/-/grunt-cli-1.2.0.tgz npm WARN retry will retry, error on last attempt: Error: tunneling socket could not be established, cause=connect […]

用Node.js在dir中search文件

我目前正在尝试使用node和grunt在Windows上的特定文件夹中search几个文件。 我有一个grunt task ,它有一个读取带有JSON文件的目录的函数,但问题是,当我运行任务时,读取文件的代码不会执行任何操作。那。 我不知道如果path的引用是正确的,但我也使用path.normalize() ,它不会引发任何错误。 这是代码片段: ..// Some other code var fs = require('fs'), path = require("path"); grunt.registerTask('separate', function() { var filePath = path.normalize("C:\Users\jbernhardt\Desktop\testkeeper\jenkinsReports"); fs.readdir(filePath, function(err, filenames) { //This log doesn't show as it the function is not running grunt.log.writeln("Testing"); if (err) { grunt.log.writeln("Error"); return; } filenames.forEach(function(filename){ grunt.log.writeln("Testing"); }); }); …//Some more code below […]

设置环境variablesgrunt或grunt-exec

我正在尝试使用grunt-exec运行一个带有部署链接variables的javascripttesting运行器。 我试图通过使用exec:setLink设置一个环境variablesgrunt.option('link')来exec:setLink 。 在我的test_runner.js我使用process.env.TEST_LINK获取variables。 不幸的是,似乎grunt-exec不会运行诸如export(?)之类的bash命令 真的,我不在乎variables如何到达我的test_runner.js所以任何其他想法都会受到欢迎。 exec: { // DOESN'T WORK: Sets env variable with link for selenium tests setLink: { cmd: function () { return "export TEST_LINK=" + "'" + grunt.option('link') + "'"; } }, // Integration tests, needs TEST_LINK selenium: { cmd: function () { return "node test/runner/jasmine_runner.js"; } }

如何通过Grunt运行节点脚本?

我正在寻找通过我的gruntfile运行节点命令。 我只需要运行: node index.js 作为任何其他任务之前的第一项任务。 我试着四处搜寻,但还没有find答案。 我相信这可能是简单的,但我不知道如何。 我是否需要加载nmp任务? 这是我的Gruntfile的样子: "use strict"; module.exports = function(grunt) { // Project configuration. grunt.initConfig({ jshint: { all: [ 'Gruntfile.js' ], options: { jshintrc: '.jshintrc', }, }, // Before generating any new files, remove any previously-created files. clean: { tests: ['dist/*'] }, // Configuration to be run (and then tested). mustache_render: […]

grunt-init模板条件提示

我正在为我的项目创build一个新的grunt-init模板,并想知道是否有一种方法可以根据给以前的提示做出回答的条件提示。 我的主要目标是在我的项目中创build一个新模块时,能够使用Github API创build一个问题。 在询问模块信息后,我会问是否应该创build一个Github问题。 如果是的话,则要求提供受托人,里程碑,标签等信息。 如果不是,我不关心任何这些function。 现在,我可以将它们默认为空白,但我只想完全跳过这些提示。

为什么调用一个child_process命令可以使用exec而不是spawn?

为什么会这样工作: var exec = require("child_process").exec; var command = exec("grunt"); 但是这会引发一个错误: var spawn = require("child_process").spawn; var command = spawn("grunt"); 它抛出的Error: spawn ENOENT是Error: spawn ENOENT 起初我以为这可能与env ,但是exec和spawn.完全一样spawn. 我认为它必须以某种方式与Grunt有关,因为尝试git在两个工程。

无法安装/运行grunt 0.4(Win 7)

我是新来的咕噜,我刚刚尝试按照http://gruntjs.com/getting-started上的说明进行安装。 首先我安装grunt-cli: npm install -g grunt-cli 在AppData /漫游中我可以看到这些文件夹和文件: |_ node_modules/ |_ grunt-cli/ |_ grunt |_ grund.cmd 然后在我的项目目录中运行: npm install grunt 这创造: |_ node_modules/ |_ grunt/ 但是,如果我尝试运行grunt,则会收到一条错误消息,指出“grunt不被识别为内部或外部命令,可操作程序或batch file” 。 我只是试图运行grunt init:jquery的一个开始,这里解释: http : //net.tutsplus.com/tutorials/javascript-ajax/meeting-grunt-the-build-tool-for-javascript/