Yarn: Add shorthand aliases to yarn add

Created on 19 Oct 2016  路  7Comments  路  Source: yarnpkg/yarn

Do you want to request a _feature_ or report a _bug_?

_feature_

What is the expected behavior?
Add shorthand for --save --save-exact and --save-dev --save-exact like -SE and -DE

Please mention your node.js, yarn and operating system version.

Yarn Version: 0.16.0
OS: Elementary OS
Node Version: v6.2.2

cat-feature

Most helpful comment

These flags don't exist, those are npm install flags, Yarn has:

yarn add [package]                 # equiv of --save
yarn add [package] --dev           # equiv of --save-dev
yarn add [package] --peer          # equiv of --save-peer
yarn add [package] --optional      # equiv of --save-optional
yarn add [package] --exact         # equiv of --save-exact
yarn add [package] --tilde

I could see allowing these flags:

yarn add [package] -D
yarn add [package] -P
yarn add [package] -O
yarn add [package] -E
yarn add [package] -T

And a new alias for add a

yarn a [package]

All 7 comments

These flags don't exist, those are npm install flags, Yarn has:

yarn add [package]                 # equiv of --save
yarn add [package] --dev           # equiv of --save-dev
yarn add [package] --peer          # equiv of --save-peer
yarn add [package] --optional      # equiv of --save-optional
yarn add [package] --exact         # equiv of --save-exact
yarn add [package] --tilde

I could see allowing these flags:

yarn add [package] -D
yarn add [package] -P
yarn add [package] -O
yarn add [package] -E
yarn add [package] -T

And a new alias for add a

yarn a [package]

@thejameskyle Is it okay if I give this one a go?

Of course, open a PR

@thejameskyle Awesome. A couple of questions.

1) Testing
Tests are pending, and I looked through existing tests, but didn't see a good way to test yarn a [package name] invokes yarn add [package name]. Really, I only should test that the shorthand command issued is being overwritten by its actual command. So, breaking this conditional into its own function and validating its output should be the only thing necessary. I wanted to ask before refactoring, though.

2) Alias previously said, "did you mean yarn [command]?"
Was there a reason for this, or was it just to provide support who thought the aliases were already there?

I don't think we want an alias for add. It's literally 3 characters and ambiguity is already rife with random commands like npm i -d <PACKGE>.

@kittens Alright. Well, nevertheless, my tests pass locally and on circle ci, but fail on appveyor / travis-ci. No need to merge in, but if you have any insight into getting more detailed logs - that'd be really helpful.

circleci
travis-ci
appveyor

Alias for the flags were added in #1618 and #1653. Will be available in the next release!

Was this page helpful?
0 / 5 - 0 ratings