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

Implements "yarn node" #5388

Merged
merged 1 commit into from
Feb 21, 2018
Merged

Implements "yarn node" #5388

merged 1 commit into from
Feb 21, 2018

Conversation

arcanis
Copy link
Member

@arcanis arcanis commented Feb 21, 2018

Summary

This PR implements a new command called yarn node. It is meant to call Node with the correct environment to run the application. The main difference with running Node directly is that Yarn will automatically "cd" to the right directory.

Test plan

I manually ran the following commands and checked their outputs:

yarn node
yarn node -p 42
yarn node -- -p 42
yarn node script.js

I haven't written unit tests for this feature because it is relatively small and self-contained, and because I'm currently designing a new architecture for our tests, which will include tests for this feature. I prefer to spend time on this 🙂

@buildsize
Copy link

buildsize bot commented Feb 21, 2018

This change will increase the build size from 10.46 MB to 10.46 MB, an increase of 4.26 KB (0%)

File name Previous Size New Size Change
yarn-[version].noarch.rpm 906.58 KB 906.75 KB 174 bytes (0%)
yarn-[version].js 3.94 MB 3.94 MB 1.93 KB (0%)
yarn-legacy-[version].js 4.09 MB 4.09 MB 1.96 KB (0%)
yarn-v[version].tar.gz 911.76 KB 911.9 KB 141 bytes (0%)
yarn_[version]all.deb 673.38 KB 673.44 KB 60 bytes (0%)

Copy link
Member

@BYK BYK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully understand the need for this but I trust you 😃

This is essentially equivalent to having a script inside package.json making use of the $NODE environment variable we have set, right?

src/cli/index.js Outdated
if (command === commands.run || command === commands.create) {
// we are using "yarn <script> -abc", "yarn run <script> -abc", or "yarn node -abc", we want -abc to
// be script options, not yarn options
if (command === commands.run || command === commands.create || command === commands.node) {
Copy link
Member

@BYK BYK Feb 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it is time to create ARG_PROXY_COMMANDS = new Set(['run', 'create', 'node']); or add a new field to all commands, proxyArgs: boolean to determine this behavior.

@arcanis
Copy link
Member Author

arcanis commented Feb 21, 2018

This is essentially equivalent to having a script inside package.json making use of the $NODE environment variable we have set, right?

Yup! The difference being that it would give us more opportunities to do extra things on the environment if we want to (for example we could imagine logging the require calls to analyze which dependencies are not being used, or stuff like this).

@arcanis arcanis merged commit 0fb0fc0 into yarnpkg:master Feb 21, 2018
@coleturner
Copy link

Could this be used to colocate specific node versions within packages?

@arcanis
Copy link
Member Author

arcanis commented Feb 24, 2018 via email

@coleturner
Copy link

coleturner commented Feb 24, 2018 via email

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

Successfully merging this pull request may close these issues.

3 participants