Giter Site home page Giter Site logo

Add PWD option for `path` about plop HOT 7 CLOSED

plopjs avatar plopjs commented on August 16, 2024
Add PWD option for `path`

from plop.

Comments (7)

amwmedia avatar amwmedia commented on August 16, 2024 1

@bsr203 you might want to take a look at inquierer-directory by @nicksrandall. it doesn't do exactly this, but it's a very nice way to pick a specific directory

from plop.

amwmedia avatar amwmedia commented on August 16, 2024

Hey Kent, interesting idea. What is the use case where you believe this would be especially useful? In every case I've come across so far, I've found it better to build the generator so that everything it needs to execute comes from the questions asked. That way the developer doesn't need to know whether or not the CWD is important for THIS generator vs another one.

This would technically be pretty simple to do through a helper though. If you used the code you wrote above as a helper function you could declare it once at the top and reuse it in all of your paths and templates...

{
  type: 'add',
  path: '{{pwd name}}.js'
  // ...etc
}

If there's enough value in a helper like this, it could easily be built into the baked in helpers.

from plop.

kentcdodds avatar kentcdodds commented on August 16, 2024

I like the helper idea. I understand what you mean by allowing the user to provide everything that's needed for the generator. Is there a way with the prompts to provide default values? In that scenario, I could prompt the user for the path they'd like but have it default to the current working directory. I think I'd be happy with that solution if it's possible :-)

from plop.

kentcdodds avatar kentcdodds commented on August 16, 2024

Looks like that's possible. I'll close this for now. Thanks! https://www.npmjs.com/package/inquirer#question

from plop.

bsr203 avatar bsr203 commented on August 16, 2024

hi @kentcdodds I too like to have this behavior and is there any of your public repo contains this implementation? else, can you please share the snippets to enable this?

from plop.

kentcdodds avatar kentcdodds commented on August 16, 2024

Unfortunately no, and I no longer have access to that repo. But @TheMcMurder does. Maybe he'd be willing to share a code snippet.

from plop.

bsr203 avatar bsr203 commented on August 16, 2024

thanks @kentcdodds for quick response

from plop.

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.