我有一组gulp.js目标用于运行我的摩卡测试,其工作方式类似于通过gulp-mocha运行的魅力.问题:如何调试通过gulp运行的mocha测试?我想使用像node-inspector这样的东西在我的src和测试文件中设置断点,看看发生了什么.我已经能够通过直接调用节点来完成此任务:
node --debug-brk node_modules/gulp/bin/gulp.js test
Run Code Online (Sandbox Code Playgroud)
但是我更喜欢一个为我包装的gulp目标,例如:
gulp.task('test-debug', 'Run unit tests in debug mode', function (cb) {
// todo?
});
Run Code Online (Sandbox Code Playgroud)
想法?我想避免使用bash
脚本或其他单独的文件,因为我正在尝试创建可重用gulpfile
的目标,这些目标可供不知道吞咽的人使用.
这是我的最新消息 gulpfile.js
// gulpfile.js
var gulp = require('gulp'),
mocha = require('gulp-mocha'),
gutil = require('gulp-util'),
help = require('gulp-help');
help(gulp); // add help messages to targets
var exitCode = 0;
// kill process on failure
process.on('exit', function () {
process.nextTick(function () {
var msg = "gulp '" + gulp.seq + "' failed"; …
Run Code Online (Sandbox Code Playgroud) CultureInfo.GetCultureInfo()
ASP.NET 5(vNext)中的等价物是什么?在针对ASP.NET Core 5.0进行编译并尝试调用该方法时,我收到以下错误:
ASP.NET Core 5.0错误CS0117:'CultureInfo'不包含'GetCultureInfo'的定义
我想启动一个gulp.src
流,将其传递给一个创建一堆新流的函数,然后将其结果传递给gulp.dest
.下面是我到目前为止所做的,但它显然不起作用,因为我正在将流回流到gulp.dest
哪个爆炸,因为它期待一个文件,而不是一个流.所以我的问题是:如何正确地将n
流的数量返回到gulp的原始流,以便它们可以适当地继续沿着管道向下移动?
//gulpfile.js
var gulp = require('gulp'),
bundle = require('./lib/bundle.js');
gulp.task('bundle', function() {
return gulp.src('./bundle.config.js')
.pipe(bundle())
.pipe(gulp.dest('./public'));
});
Run Code Online (Sandbox Code Playgroud)
-
//bundle.config.js
module.exports = {
bundle: {
main: {
js: [
'./content/js/foo.js',
'./content/js/baz.js'
],
css: [
'./content/**/*.css'
],
resources: './content/**/*.{png,svg}'
},
other: {
js: './content/js/other.js',
css: '',
resources: ''
}
}
};
Run Code Online (Sandbox Code Playgroud)
-
//bundle.js
var gulp = require('gulp'),
through = require('through2'),
concat = require('gulp-concat');
module.exports = function () {
return through.obj(function (file, enc, cb) { …
Run Code Online (Sandbox Code Playgroud) 我正在使用grails 2.2.1并尝试验证嵌套的命令结构.这是我的命令对象的简化版本:
@Validateable
class SurveyCommand {
SectionCommand useful
SectionCommand recommend
SurveyCommand() {
useful = new SectionCommand(
question: 'Did you find this useful?',
isRequired: true)
recommend = new SectionCommand(
question: 'Would you recommend to someone else?',
isRequired: false)
}
}
@Validateable
class SectionCommand {
String question
String answer
boolean isRequired
static constraints = {
answer(validator: answerNotBlank, nullable: true)
}
static answerNotBlank = { String val, SectionCommand obj ->
if(obj.isRequired) {
return val != null && !val.isEmpty()
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试验证SurveyCommand …
我正在尝试在我的页面上实施Google 跟踪代码管理器脚本,但它抛出了错误。我将 html 页面精简为最简单的内容:
<html>
<head>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXX');</script>
</head>
<body>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
但我仍然看到控制台中抛出以下错误:
Uncaught TypeError: Cannot read property 'test' of undefined
at <anonymous>:14:12
at gtm.js?id=GTM-XXXX:57
at Object.Th (gtm.js?id=GTM-XXXX:59)
at sf (gtm.js?id=GTM-XXXX:31)
at uk.B (gtm.js?id=GTM-XXXX:90)
at ag (gtm.js?id=GTM-XXXX:99)
at jg (gtm.js?id=GTM-XXXX:39)
at Array.a.push (gtm.js?id=GTM-XXXX:105)
at Array.<anonymous> (gtm.js?id=GTM-XXXX:105)
at Lf (gtm.js?id=GTM-XXXX:34)
Run Code Online (Sandbox Code Playgroud)
GA 调试器 Chrome 扩展显示脚本仍在“工作”,即所有正确的 ga 方法都在触发。我只是关心这个错误是什么。
请注意,我在 Firefox 和 Safari 中也遇到了相同的错误(跟踪看起来略有不同,但它是相同的错误):
TypeError: undefined is not an object (evaluating 'tryformurls.test')
Global Code (Script Element …
Run Code Online (Sandbox Code Playgroud) 我正在使用React.js动态创建一个包含文本框的html表.我有行可以通过按钮单击删除.我希望,当我点击第一行上的"删除"时,表格将重新呈现,并删除第1行.但是,当react重新绘制表时,看起来它总是从DOM中删除表的最后一行,而不是使用我state
对象的实际值.也许我发现了一个bug?这是我的代码:
/** @jsx React.DOM */
var MyApp = React.createClass({
getInitialState: function () {
return {
col_one: ['c1r1', 'c1r2', 'c1r3'],
col_two: ['c2r1', 'c1r2', 'c1r3'],
col_three: ['c3r1', 'c3r2', 'c3r3']
}
},
handleCellChange: function (colName, index, e) {
console.log('onChange:', colName, index, e.target.value);
},
handleRemove: function (i) {
var that = this;
console.log('removing row:',i);
_.forEach(this.state, function (val, colName) {
that.state[colName].splice(i,1); // BUG???
//_.pullAt(that.state[key], i); // doesn't work either
});
console.log(this.state);
this.setState(this.state);
},
render: function() {
var that = this,
rows = [], …
Run Code Online (Sandbox Code Playgroud) gulp ×2
javascript ×2
node.js ×2
.net ×1
asp.net ×1
asp.net-core ×1
grails ×1
grails-2.0 ×1
react-jsx ×1
reactjs ×1
stream ×1