Giter Site home page Giter Site logo

Double-check API about cosmiconfig HOT 27 CLOSED

cosmiconfig avatar cosmiconfig commented on May 30, 2024
Double-check API

from cosmiconfig.

Comments (27)

davidtheclark avatar davidtheclark commented on May 30, 2024

cc/ @keithamus

from cosmiconfig.

keithamus avatar keithamus commented on May 30, 2024

It looks to do what I want from it πŸ˜„.

However, I would suggest that it does not parse process.argv, and instead I have to manually pass you the option which I have parsed from the command line. I wouldn't want it to change behaviour through external options - only the options I feed into the function. But it's your code so you do what you want πŸ˜‰

from cosmiconfig.

TrySound avatar TrySound commented on May 30, 2024

@keithamus Maybe make it optional? @davidtheclark Is it optional?

from cosmiconfig.

davidtheclark avatar davidtheclark commented on May 30, 2024

@keithamus : Thanks for the feedback. I was on the fence about --config and kind of did it just because rc was doing it so I assumed people liked it .... I do admit, though, that I can't think of a reason not to push the process.argv parsing into the user's court.

@TrySound : It's not optional currently but would be very easy to make optional.

from cosmiconfig.

TrySound avatar TrySound commented on May 30, 2024

@davidtheclark I think every feature should be optional

from cosmiconfig.

davidtheclark avatar davidtheclark commented on May 30, 2024

@TrySound : So you'd suggest lots more options --- for turning off YAML, JSON, or JS parsing, not looking in package.json, not looking for module.config.js, etc?

from cosmiconfig.

TrySound avatar TrySound commented on May 30, 2024

@davidtheclark I'm about searching rc, config, global and argv. Parsing don't need to complicate.

from cosmiconfig.

TrySound avatar TrySound commented on May 30, 2024

@davidtheclark Also I don't understand, why need parse-json if yaml can parse json out of the box. And first symbol checking do not make guarantee correct detecting.

from cosmiconfig.

davidtheclark avatar davidtheclark commented on May 30, 2024

@TrySound : parse-json throws extra nice JSON errors, so I thought it might be handy. More importantly, though, I was finding that YAML was weirdly lenient in its JSON parsing? Maybe I misunderstood --- could test it out more. I agree that the first symbol checking is not great: open to a better way.

from cosmiconfig.

TrySound avatar TrySound commented on May 30, 2024

@davidtheclark I think it's a good feature for rc file. It's multiformat file. So, why we shoundn't let it be free?

from cosmiconfig.

TrySound avatar TrySound commented on May 30, 2024

@davidtheclark And need to add appveyor support. On windows tests fails

from cosmiconfig.

MoOx avatar MoOx commented on May 30, 2024

from cosmiconfig.

TrySound avatar TrySound commented on May 30, 2024

@davidtheclark I'd like to suggest you to use this publishing way https://github.com/sindresorhus/np/blob/master/np.sh
Also if you use npm3 you can add some good hooks
https://github.com/TrySound/postcss-inline-svg/blob/master/package.json#L37-L42

from cosmiconfig.

keithamus avatar keithamus commented on May 30, 2024

FYI those scripts also work for npm2. In fact they also work for npm1 πŸ˜‰. http://blog.keithcirkel.co.uk/how-to-use-npm-as-a-build-tool/

from cosmiconfig.

TrySound avatar TrySound commented on May 30, 2024

@keithamus Oh, cool. I just heard from somebody that they are not reliable, but in npm3 works fine. Maybe just a noise in my head :))

from cosmiconfig.

keithamus avatar keithamus commented on May 30, 2024

They're pretty darn reliable. I've been using them for about 2 years now, so long before npm3 came out. Never had a problem with them.

@davidtheclark you could also look at https://github.com/semantic-release/semantic-release - which takes a while to set up, but could manage all of your releases automatically for you πŸŽ‰

from cosmiconfig.

davidtheclark avatar davidtheclark commented on May 30, 2024

I've never been too annoyed by typing the git and npm commands manually, but will look into the scripts. Thanks for the suggestions!

And thanks for all the feedback above. Based on what's been said so far, here are some changes I think could be made:

  • Add noJs, noRc, noPackageProp, and noArgv options, each of which turns off one of the places this module might look.
  • Add appveyor CI.

@TrySound I prefer keeping JSON strict instead of the leniency allowed by yaml parsing. If I have a .json file, I want it to be valid JSON. I will double-check my reasoning for including parse-json, though, because I don't exactly remember the details :)

from cosmiconfig.

TrySound avatar TrySound commented on May 30, 2024

@davidtheclark Maybe better {js:true, rc:true, packageProp:true, argv:true, strictJSON:false} ?

from cosmiconfig.

ben-eb avatar ben-eb commented on May 30, 2024

I find positive options to be less confusing than negative ones.

from cosmiconfig.

davidtheclark avatar davidtheclark commented on May 30, 2024

Good suggestion.

from cosmiconfig.

TrySound avatar TrySound commented on May 30, 2024

@davidtheclark I didn't mean json files parsing with yaml. Only .[moduleName]rc file. It should have free format.

from cosmiconfig.

TrySound avatar TrySound commented on May 30, 2024

@davidtheclark Can argv extends file config? Like here

from cosmiconfig.

TrySound avatar TrySound commented on May 30, 2024

@davidtheclark However let's do not extend. Just rewrite. If somebody want to extend it he can disable default argv.

from cosmiconfig.

davidtheclark avatar davidtheclark commented on May 30, 2024

That sounds like a good feature, yep.

from cosmiconfig.

davidtheclark avatar davidtheclark commented on May 30, 2024

@TrySound : Actually, I'm second-guessing -- are you saying that if the configuration might have a format property, the module user could set or override that with --format something? I think that might be too app-specific: we don't want to check all the CLI arguments by default and plug them into the config. Considering how simple it should be for the cosmiconfig user to handle CLI arguments themselves and determine exactly what should get included in the config, vs what should do something else, I'm not sure cosmiconfig should try to address that.

from cosmiconfig.

davidtheclark avatar davidtheclark commented on May 30, 2024

By closing #11 and #12 I think all the feedback above is addressed. If anybody feels like taking a second look at the docs to reassess, feedback would be much appreciated -- just open an issue!

from cosmiconfig.

davidtheclark avatar davidtheclark commented on May 30, 2024

Also current version is published as 0.5.0, if you want to try it out and see if it does the job.

from cosmiconfig.

Related Issues (20)

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.