Comments (8)
Hey thanks for reporting! Looking into this...
from grunt-contrib-nodeunit.
So it's either the case that:
- The user has
grunt-contrib-nodeunit
listed as a dependency, and notnodeunit
as a dependency. - The user has both
grunt-contrib-nodeunit
andnodeunit
installed as a dependency (probably the more likely case, and the problem listed by @weemonger).
I wasn't aware that if you are dependent on both A and B, and A requires B, that it won't install its own copy of B (probably unless you have specific version requirements that differ).
#23 solved case number 1 above.
My thoughts are we could simply also look for ../../node_modules/nodeunit/bin/nodeunit.json
instead of just ../node_modules/nodeunit/bin/nodeunit.json
. Shouldn't that cover all cases?
from grunt-contrib-nodeunit.
PR #25 should fix it.
from grunt-contrib-nodeunit.
It is possible that the nodeunit package is even further up the directory tree.
I think of a grunt-collection-plugin:
myApp - package.json:
"dev-dependencies": {
"a-grunt-collection-plugin": "~x.y.z",
"nodeunit": "~a.b.c"
}
a-grunt-collection-plugin - package.json
"dependencies": {
"grunt-contrib-nodeunit": "~d.e.f",
...
}
grunt-contrib-nodeunit - package.json
"dependencies": {
"nodeunit": "~a.b.c"
}
The result dependency-tree of my-app should be:
myapp
└── node_modules
├── a-grunt-collection-plugin (version: x.y.z)
│ └── node_modules
| └── grunt-contrib-nodeunit (version: d.e.f)
└── nodeunit (version: a.b.c)
├── bin
...
Could require(nodeunit.json) be used to find the file, regardless where in the node_modules-tree it is?
from grunt-contrib-nodeunit.
I don't think require()
can be used to get an arbitrary file from another module (though I haven't tested it).
Theoretically we could use the same logic that require()
does, going infinitely up the tree looking for node_modules\nodeunit\bin\nodeunit.json
.
Are there current cases of grunt plugin collections that would need this logic?
from grunt-contrib-nodeunit.
You are right, nicjansma. require()
can't be used like that.
I think the easiest way is to ask @caolan to export the nodeunit.json file as 'defaultOptions' of nodeunit,
so it can be used like that:
nodeUnitDefaults = require('nodeunit').defaultOptions;
Regarding your last question, if there are current cases of grunt plugin collections with such a need:
Currently - I can't say, but I am planing to write one myself (at least for my current employee) to encapsulate our standard build process and configuration, to use it easily in many projects.
But if you don't want to support this case, it is fine for me - I can help myself, and define the defaultOptions in the task config.
If I find the time this week, I will contact @caolan and/or create a pull-request for nodeunit to export the nodeunit.json file.
If nobody else is interested in this issue, it can be closed, imho.
Thanks for your time and effort.
from grunt-contrib-nodeunit.
Hi,
I stumbled over this interesting snippet
var fooVersion = require('foo/package.json').version
in an example for optionalDependencies on https://www.npmjs.org/doc/files/package.json.html.
A short test, ala
nodeUnitDefaults = require('nodeunit/bin/nodeunit.json');
was succesfull.
Expect a PullRequest after a more serious test.
Any tips, regarding a unit-test for this, are welcome.
from grunt-contrib-nodeunit.
Published 0.3.3 that should fix this issue for you. It would be great for Nodeunit to "export the nodeunit.json" but it's up to them. Feel free to PR to make the defaults load better if necessary.
from grunt-contrib-nodeunit.
Related Issues (20)
- NPM does not show version 0.3.0 HOT 4
- reporter type "junit" is not working HOT 3
- `undefined` in output using minimal reporter HOT 10
- Passing values from grunt to nodeunit tests HOT 4
- Directory structure too deep to do a git commit on Windows HOT 2
- Undone tests cause task to die without output HOT 4
- error.stack is erroneously assumed to exist
- Different output running with grunt-contrib-nodeunit vs plain nodeunit HOT 3
- file paths in nodeunit.options.reporter
- Test failures after 45f2a9b
- Upgrade nodeunit dependency to ^0.9.1 to fix task running on node 0.12.X HOT 2
- On crash exit value is still 0 HOT 1
- Fix errors caught by travis ci
- test only one--grunt nodeunit:all:sometest HOT 1
- Can you bump a new version for Grunt v1.0.0? HOT 1
- Newbie needing advice on handling exceptions in a node unit.
- error while running same grunt nodeunit task twice
- Missing tag HOT 1
- please address known security vulnerabilities
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grunt-contrib-nodeunit.