Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spawn Mocha instead of using its API #151

Merged
merged 3 commits into from
Feb 20, 2017
Merged

Spawn Mocha instead of using its API #151

merged 3 commits into from
Feb 20, 2017

Conversation

shellscape
Copy link
Contributor

@shellscape shellscape commented Feb 9, 2017

this PR fixes #20 and provides resolution to most of the other remaining issues.

notes:

  • using through2 instead of through
  • require and cache features removed as they were no longer needed
  • tests have been updated to reflect changes
  • emitting error and result events. result events provides for testing the command result without having to override output methods.
  • tabs -> spaces and minor XO rule changes (I'll change this back if there is pushback)

this is a first-pass, and welcoming comments.

@ferlores
Copy link

ferlores commented Feb 9, 2017

+1 we are having the same problems and it seems this will fix it

@sindresorhus
Copy link
Owner

Good start. Thanks for working on this 🎉

Can you make sure the options in the readme matches the CLI flags (in a camelCased version)?


tabs -> spaces and minor XO rule changes (I'll change this back if there is pushback)

Should be changed back. Use EditorConfig and $ xo --fix and you don't even have to think about it being tab indented ;)

.gitignore Outdated
@@ -1 +1,2 @@
node_modules
*-backup.*
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in your own local gitignore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aye

.travis.yml Outdated
- '0.10'
- 4
- 6
- 7
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These needs to be quoted

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious. none of my other projects have these quoted and travis works as expected. please do share why

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YAML interprets them as number, but versions are not number in this sense. They should be quoted for consistency. It's only a quirk that they work now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to know, thanks

index.js Outdated
if (options.suppress) {
suppress = true;
delete options.suppress;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, just use the excludes option in dargs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aye

index.js Outdated
}
}
}
options = Object.assign({colors: true}, options || {});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

options || {} => options

Object.assign handles it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to know. old school habits persist hard :)

package.json Outdated
@@ -1,6 +1,6 @@
{
"name": "gulp-mocha",
"version": "3.0.1",
"version": "4.0.0",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't bump this. We'll do it at publish time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool. will revert

package.json Outdated
@@ -10,7 +10,7 @@
"url": "sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
"node": ">=4.6.2"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"node": ">=4"

package.json Outdated
},
"devDependencies": {
"mocha": "^3.0.0",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mocha should be a dependency

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah. I had thought the ecosystem was moving towards the pattern that gulp-jshint is using now; where jshint is a peerDep. Will remedy.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peerdependencies are annoying for everyone, now that npm@3 dedupes by default, the user can just add mocha to their own package.json with a more specific version and it will be deduped to that version and we'll use it too as long as it's in the v3 range.

@sindresorhus sindresorhus changed the title Spawn mocha Spawn Mocha instead of using its API Feb 13, 2017
@shellscape
Copy link
Contributor Author

requested changes made. I manually verified the command line options from camelCase. didn't see a need to add that to tests as dargs tests handle that.

process.stdout.write(result.stdout);
}

this.emit('result', result);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be documented.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was only meant to be used internally for tests

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then it should be prefixed with an underscore: _result


options = Object.assign(defaults, options);

if (Object.prototype.toString.call(options.globals) === '[object Array]') {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Array.isArray()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's not compatible with with node < 6. http://node.green/#Array-isArray-support

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is. You're looking at proxy support. Array.isArray() has been available since at least Node.js 0.10.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, my fault there.

@@ -42,6 +42,10 @@ gulp.task('default', () =>

#### options

gulp-mocha will pass any options defined directly to the `mocha` binary. That
means you have every [command line option](http://mochajs.org/#usage) available
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be explicit about it users using a camelCased version of those command line options.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dargs doesn't require that you use only camelCased args, it treats the arguments the same if they're in sausage case (the format of the mocha args) as well.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not the point. Users don't want to use quotes in the keys. And they wouldn't even know camelCase is supported.

@shellscape
Copy link
Contributor Author

I'm going to leave this to someone else to touch up the finer, stylistic comments on this PR. The high standards you hold this to are admirable, but just a tad on the nitpicky side of the line for my tastes. The turn-around time on review for the stylistic change requests has been a bit long as well. And that's said completely devoid of any amount of sarcasm, snide, ill-will, or negativity. I'm extremely grateful for your time and massive contribution to the node ecosystem.

@sindresorhus
Copy link
Owner

sindresorhus commented Feb 20, 2017

@shellscape I did a thorough review because I thought you wanted to learn. It would have indeed been much much faster for me to just fix everything after merging. You shouldn't expect maintainers to clean up your mess though. Pull requests reviews are meant to get the code into an acceptable state before being merged into master. Once it's in master, it's the maintainers job to maintain it, so obviously they want it to be good before it ends up there.

I appreciate the pull request though :)

@sindresorhus sindresorhus merged commit 3e55175 into master Feb 20, 2017
@sindresorhus sindresorhus deleted the spawn-mocha branch February 20, 2017 14:44
sindresorhus added a commit that referenced this pull request Feb 20, 2017
sindresorhus added a commit that referenced this pull request Feb 20, 2017
@shellscape
Copy link
Contributor Author

shellscape commented Feb 20, 2017

I appreciate the sentiment. While I'm always expanding what I know, I consider myself to be a seasoned developer (your opinion may vary, and that's OK). This wasn't a learning exercise for me, so to speak. I was interested in coming on as a maintainer, which is why I contacted and spoke about what direction the code needed to go in, rather than releasing a different module. And in that role (a maintainer) I would have been very comfortable with the PR as it was this morning. That moves to highlight our differences, which is OK. If you're ever to the point where you're good letting go of the reigns, give me a shout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider integrating the problems gulp-spawn-mocha had tried to solve
3 participants