Giter Club home page Giter Club logo

Comments (8)

typicode avatar typicode commented on June 14, 2024

Good point! Do you want to make a PR?

from please-upgrade-node.

stramel avatar stramel commented on June 14, 2024

Hm, personally I like the ability to pass in an object

from please-upgrade-node.

tracker1 avatar tracker1 commented on June 14, 2024

@stramel It could be an object or string, if object, just returns the object, otherwise returns require(INPUT_VALUE)

from please-upgrade-node.

typicode avatar typicode commented on June 14, 2024

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.

Dan503 avatar Dan503 commented on June 14, 2024

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.

typicode avatar typicode commented on June 14, 2024

@Dan503 hmm could be very smart, don't know if there would be some edge cases or not.

from please-upgrade-node.

Dan503 avatar Dan503 commented on June 14, 2024

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.

typicode avatar typicode commented on June 14, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.