Tag: gruntjs

Grunt – 如何从外部项目运行常见的外部任务

我刚开始使用Grunt,我想有一个可以定义常见任务的公共项目。 之后,每个团队都可以创build自己的项目,并能够将我的通用项目添加为依赖项,并运行常见任务。 当您想要将一些预定义的任务添加到您的FE构buildpipe道时也很有帮助。 当有人把这个项目推到github上并试图使用它,比方说,jenkins,那么我也想默认运行一些其他的任务(如jslint,uglify,compress,nexus deploy等)。 我尝试通过创build一个包含所有常见任务的grunt项目,然后将其作为依赖添加到其他项目中。 问题是我不能从外部项目运行常见的任务。 有没有另一种方法来实现这一目标?

使用load-grunt-tasks有什么缺点吗?

我最近遇到了负载咕tasks任务的高效魔法,但我想知道为什么它的使用似乎是例外,而不是我见过的大多数例子中的规则。 如果你不熟悉这个模块,它会这样做: 该模块将读取package.json中的dependencies/devDependencies/peerDependencies并加载与提供的模式匹配的grunt任务。 例如,在你的Gruntfile.js中这个混乱: grunt.loadNpmTasks('grunt-shell'); grunt.loadNpmTasks('grunt-sass'); grunt.loadNpmTasks('grunt-recess'); grunt.loadNpmTasks('grunt-sizediff'); grunt.loadNpmTasks('grunt-svgmin'); // and likely many, many more …可以用一个简单的replace: require('load-grunt-tasks')(grunt); 那么,这个单线是否有任何缺点? 如果不是,那为什么它不是在线例子中注册Grunt任务的标准? 我在SO或Googz上找不到任何东西,对Node或Grunt也不是很熟悉,所以对此有所了解。

使用Mocha和Grunt在Sails.js中运行functiontesting时的竞态条件

我正在使用Sails v0.10.x,并且在运行我的functiontesting时遇到问题。 testing/ bootstrap.test.js // force the test environment to 'test' process.env.NODE_ENV = 'test'; var Sails = require('sails'); // use zombie.js as headless browser var Browser = require('zombie'); // Global before hook before(function(done) { var self = this; // Lift Sails and start the server Sails.lift({ log: { level: 'error' }, }, function(err, sails) { […]

我怎样才能看到在黄瓜JS错误的头?

我正在尝试使用一个咕噜触发的Cucumber JS任务与nodeJS的一些BDD,这是工作正常,但我不想看到一个testing,我知道当然会失败,完整的JSexception堆栈。 相反,我宁愿只看到exception的(更有用的)头。 这看起来可能微不足道,但我相信BDD最好的实现是通过这些工具的快速反馈。 作为一个例子,下面是来自一个模块的基本缺失方法的完整堆栈跟踪: TypeError: Object #<Object> has no method 'delete' at World.<anonymous> ($HOME/features/step_definitions/delete-item.steps.js:20:21) at Object.invoke ($HOME/node_modules/grunt-cucumber/node_modules/cucumber/lib/cucumber/support_code/step_definition.js:84:14) at Object.execute ($HOME/node_modules/grunt-cucumber/node_modules/cucumber/lib/cucumber/ast/step.js:157:22) at Object.acceptVisitor ($HOME/node_modules/grunt-cucumber/node_modules/cucumber/lib/cucumber/ast/step.js:149:12) at Object.executeStep ($HOME/node_modules/grunt-cucumber/node_modules/cucumber/lib/cucumber/runtime/ast_tree_walker.js:178:12) at Object.processStep ($HOME/node_modules/grunt-cucumber/node_modules/cucumber/lib/cucumber/runtime/ast_tree_walker.js:173:14) at $HOME/node_modules/grunt-cucumber/node_modules/cucumber/lib/cucumber/runtime/ast_tree_walker.js:66:16 at callUserFunctionAndBroadcastAfterEvent ($HOME/node_modules/grunt-cucumber/node_modules/cucumber/lib/cucumber/runtime/ast_tree_walker.js:90:9) at iterate ($HOME/node_modules/grunt-cucumber/node_modules/cucumber/lib/cucumber/type/collection.js:14:11) at Object.forEach ($HOME/node_modules/grunt-cucumber/node_modules/cucumber/lib/cucumber/type/collection.js:23:7) at broadcastToListeners ($HOME/node_modules/grunt-cucumber/node_modules/cucumber/lib/cucumber/runtime/ast_tree_walker.js:117:19) at onRuntimeListenersComplete ($HOME/node_modules/grunt-cucumber/node_modules/cucumber/lib/cucumber/runtime/ast_tree_walker.js:113:9) at iterate ($HOME/node_modules/grunt-cucumber/node_modules/cucumber/lib/cucumber/type/collection.js:14:11) at $HOME/node_modules/grunt-cucumber/node_modules/cucumber/lib/cucumber/type/collection.js:20:11 at hear ($HOME/node_modules/grunt-cucumber/node_modules/cucumber/lib/cucumber/listener.js:8:9) […]

testingGrunt任务

我正在使用Yeoman来生成一些项目和咕-任务。 现在我也想使用Mocha来testing生成的grunt任务,但是我只能find一些如何在Grunt中使用Mochatesting的信息;-) 任何人都可以帮忙吗?

用debug-brk启动Sails不会运行Grunt?

当我没有debugging或仅使用–debug启动sails,并且包含–verbose作为应用程序参数时,它会显示它运行的grunt的详细信息(请参阅下面的第一个日志示例)。 但是,当我用debug-brk =运行应用程序时,它不会运行grunt。 (请参阅下面的第二个日志示例)。 我发布了这个在不同的论坛,有人build议“最可能的咕噜生成一个subprocess使用相同的debugging端口作为父应用程序…而且,由于端口已经绑定,它已被暂停”。 证据似乎支持这一点,但我无法find咕噜模块越过sails模块中的端口的位置。 有没有人遇到过这个? 我会认为这会是一件普通的事情,我错过了一些明显的东西。 问候 我正在使用…帆子0.10.5节点0.10.29咕噜0.4.5咕噜声0.1.13 这是一个很好的运行的例子..没有debugging或只有–debug(不是–debug-brk) C:\Users\myuser\git\datavis>node app.js –verbose verbose: Setting Node environment… verbose: Please run `npm install coffee-script` to use coffescript (skipping for now) verbose: moduleloader hook loaded successfully. verbose: Loading app config… verbose: userconfig hook loaded successfully. verbose: Exposing global variables… (you can disable this by modifying the […]

Microsoft Azure持续集成 – 使用Grunt“编译”步骤的NodeJs解决scheme

我的问题的一些前兆。 我可能会有一些详细的细节,但我只是想确保我不会遗漏任何可能导致我的问题。 (我会在问题的末尾附上完整的错误日志,但是我不希望任何人对此有太大的反应,我会尽可能地总结一下) 我使用Yeoman支撑了一个AngularJS项目。使用yo angular命令。 然后我创build了deploy.cmd & .deployment文件 推到我的Git仓库上的Bitbucket。 (只提交根文件夹文件,testing和应用程序文件夹) 从那里,通过他们的网站快速设置链接到Azure。 我的版本分成两部分,在部署期间安装grunt和bower(全局),然后在npm软件包安装期间安装grunt软件包 然后我需要尝试运行grunt build成为POST_DEPLOYMENT_ACTION package.json (prod依赖) "dependencies": { "grunt": "^0.4.1", "grunt-autoprefixer": "^0.7.3", "grunt-concurrent": "^0.5.0", "grunt-contrib-clean": "^0.5.0", "grunt-contrib-concat": "^0.4.0", "grunt-contrib-copy": "^0.5.0", "grunt-contrib-cssmin": "^0.9.0", "grunt-contrib-htmlmin": "^0.3.0", "grunt-contrib-imagemin": "^0.8.1", "grunt-contrib-jshint": "^0.10.0", "grunt-contrib-uglify": "^0.4.0", "grunt-filerev": "^0.2.1", "grunt-google-cdn": "^0.4.0", "grunt-newer": "^0.7.0", "grunt-ng-annotate": "^0.3.0", "grunt-svgmin": "^0.4.0", "grunt-usemin": "^2.1.1", "grunt-wiredep": "^1.7.0", "jshint-stylish": […]

尝试使用grunt uncss删除一些CSS

我有一个网站,我用几个巨大的css文件inheritance,用Firefox中的DUst-Me Selector进行分析,返回了我近2000个未使用的样式。 要删除它们,我正在尝试使用grunt uncss,问题是我得到以下错误: grunt uncss Running "uncss:dist" (uncss) task Fatal error: uncss/node_modules/css: missing '}' near line 2429:5 -> .mobile-hidden { 这些是我的configuration文件 的package.json { "name": "tappr-registration", "version": "0.1.0", "devDependencies": { "grunt": "~0.4.5", "grunt-contrib-copy": "^0.7.0", "grunt-contrib-jshint": "~0.10.0", "grunt-contrib-nodeunit": "~0.4.1", "grunt-contrib-uglify": "^0.6.0", "grunt-processhtml": "^0.3.3", "grunt-uncss": "^0.3.7" } } Gruntfile.js module.exports = function(grunt) { // Project configuration. grunt.initConfig({ […]

TypeScript – 使用Grunt在后台编译TypeScript

我有一个networking应用程序与Node.js和一些TypeScript文件被用来创build一个更复杂的types安全引擎来做大量的工作。 这在概念上以几种方式推动我的理解的界限,但是这里有一些假设: 对于开发,当我创build新的TypeScript文件时,每次testing我的程序时都需要重新编译为JavaScript。 对于生产,我可以部署已经编译好的TypeScript —> JavaScript,所以我不相信在用户运行应用程序时需要编译。 我想用Grunt编译我的TypeScript,如果这是最好的select。 在使用时有没有任何竞争条件需要担心 https://www.npmjs.org/package/grunt-typescript 编译成JavaScript,其他JavaScript文件可能需要或从我新编译的TypeScript中调用函数?

使用Gruntreplace文件中的文本

我试图让Gruntreplace一个path引用,我不知道我做错了什么。 这看起来应该工作。 从本质上讲,我将Bootstrap文件复制到目录并更改@importpath,所以我只是试图用新的目标path'MY / NEW / DEST / PATH / bootstrap'replace'bootstrap /'。 我不想用一个模块来expression这样的东西,似乎是不必要的。 一切工作,但取代。 var destFilePath = path.join(basePath, file); // Does the file already exist? if (!grunt.file.exists(destFilePath)) { // Copy Bootstrap source @import file to destination grunt.file.copy( // Node API join to keep this cross-platform path.join(basePath, 'bootstrap/_bootstrap.scss'), destFilePath ); // Require node filesystem module, since […]