Comments (8)
Good point! Do you want to make a PR?
from please-upgrade-node.
Hm, personally I like the ability to pass in an object
from please-upgrade-node.
@stramel It could be an object or string, if object, just returns the object, otherwise returns require(INPUT_VALUE)
from please-upgrade-node.
I've created a PR to change the API #3
For the moment, I don't see reasons not to use the package directory instead (maybe there are)?
from please-upgrade-node.
I'm thinking that it would be possible to avoid having to parse in the package.json entirely.
The folder structure is pretty much always going to look like this:
[Root]
- node_modules
- - please-upgrade-node
- - - index.js
- package.json
If inside index.js you have the following:
var pkg = require("../../package.json");
You could then call please-upgrade-node by just doing this in the vast majority of cases:
require("please-upgrade-node")();
It should use that by default but people could then override the default by parsing in an object or a string to a package.json that is in a weird location.
from please-upgrade-node.
@Dan503 hmm could be very smart, don't know if there would be some edge cases or not.
from please-upgrade-node.
If there are edge cases, then that is why you would allow people to still parse in a custom package.json object of their own. That would override the default of looking for the typical package.json set up.
This is just how I think the default behavior should act since the folder structure in 99.99% of installs would be identical.
Allowing people to parse in a string is going to be problematic since a relative string in one file will point to a different location than a relative string in another. Allowing the parsing in of strings would surely lead to an avalanche of bugs.
I think my solution gets at the core of the issue in that developers are lazy and want to type as little as possible.
This wouldn't even be a breaking change since all current implementations would simply be using the overide functionality instead of the default functionality.
from please-upgrade-node.
Actually, I've rolled back to the first approach:
#!/usr/bin/env node
const pkg = require('./package.json')
require('please-upgrade-node')(pkg)
It's less smart but easier to debug and understand (that's also how they do in https://github.com/yeoman/update-notifier).
I've also (re)discovered that it's possible to use const
with Node 0.12 (unless you add use strict;
), so there was no need to have a caveat section actually, the example should work down to 0.12.
Thank you all for the feedbacks and PRs :)
from please-upgrade-node.
Related Issues (10)
- Fails for version comparisons <10 versus v10+ HOT 6
- how to use with express and typescript require ? HOT 1
- Add CLI please HOT 1
- Throw an error instead of using process.exit HOT 2
- NVM cus get the wrong Node Verison
- bug: Does not handle `>`
- Suggested usage errors out
- Feature request: .nvmrc HOT 1
- Semver ranges: use "semver" package HOT 3
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 please-upgrade-node.