Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect if Yarn is in use #17

Open
Daniel15 opened this issue Sep 1, 2018 · 6 comments
Open

Detect if Yarn is in use #17

Daniel15 opened this issue Sep 1, 2018 · 6 comments
Labels

Comments

@Daniel15
Copy link

Daniel15 commented Sep 1, 2018

"pwa init" outputs the following:

      These commands have been added to your package.json already.
      We suggest you begin by typing:

        $ cd pwareacttest
        $ npm install
        $ npm run watch

However, If I'm using Yarn, it should suggest Yarn rather than npm. A system that has Yarn might not even have npm installed. create-react-app is an example of an app that detects if Yarn is being used.

@lukeed
Copy link
Owner

lukeed commented Sep 1, 2018

Hey!

I think "in use" is a a bit ambiguous, as simply having something installed on a system doesn't mean it's actually being used or preferred. I stopped the generator before installation so that users can use whatever they want for the actual expensive task.

I think the best I can do here is adding a --yarn flag that prints and includes yarn commands. Even then I'm hesitant because anyone who's actually using yarn/pnpm is smart enough to know how to run the npm * commands in their flavor.

@Daniel15
Copy link
Author

Daniel15 commented Sep 1, 2018

Hmm, that makes sense. I wonder what create-react-app does.

@lukeed
Copy link
Owner

lukeed commented Sep 1, 2018

TBH I could have sworn that they printed npm run commands in the message. Maybe it's changed since?

@lukeed lukeed added the maybe label Sep 1, 2018
@Daniel15
Copy link
Author

Daniel15 commented Sep 1, 2018

I ran yarn create react-app testcra and it output this at the end:

Success! Created testcra at C:\src\testcra
Inside that directory, you can run several commands:

  yarn start
    Starts the development server.

  yarn build
    Bundles the app into static files for production.

  yarn test
    Starts the test runner.

  yarn eject
    Removes this tool and copies build dependencies, configuration files
    and scripts into the app directory. If you do this, you can’t go back!

We suggest that you begin by typing:

  cd testcra
  yarn start

@Daniel15
Copy link
Author

Daniel15 commented Sep 1, 2018

@lukeed Looks like create-react-app decides to use Yarn based on whether there's a yarn.lock file in the directory: https://github.com/facebook/create-react-app/blob/26f701fd60cece427d0e6c5a0ae98a5c79993640/packages/react-scripts/scripts/init.js#L88

@lukeed
Copy link
Owner

lukeed commented Sep 1, 2018

Okay, but that still doesn't make sense for this use case. The init creates new directories, and in the event you select the cwd you have to go thru two confirmation steps to make sure it's intended. I'd assume/hope that 99% of inits are not into existing directories 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants