Mac alias for npm install && bower install

0

1

How can I assign this alias to my new mac with Yosemite?

alias in = "npm install && bower install"

SuperUberDuper

Posted 2015-02-13T16:16:04.463

Reputation: 135

Answers

1

Add the alias directive to your ~/.bashrc file. You'll need to remove the spaces around the = symbol for bash to parse the command correctly:

alias in="npm install && bower install"

You could allow the caller to specify a package name if you use a shell function instead of an alias. Here we pass the same argument to both npm and bower (note, use "$@" instead of $1 if there is more than one argument):

in() {
    npm install $1 && bower install $1
}

Also see https://stackoverflow.com/questions/15364259/automating-npm-install-bower-install-dev-with-generator-angular-for-yeoma

zackse

Posted 2015-02-13T16:16:04.463

Reputation: 532

do I have to shut all my terminal windows, or open new ones to use this? – SuperUberDuper – 2015-02-16T10:49:57.790

source ~/.bashrc to take effect in an existing shell. – zackse – 2015-02-17T02:03:10.910

I have this: alias sd=“—save-dev” but in terminal I type sd I get:-bash: sd: command not found – SuperUberDuper – 2015-02-18T17:37:13.590

1A bash alias can only be used as a command, not an argument. To create a shortcut for a command-line option, you would need to use an alias that includes the option (e.g., alias sd='npm install --save-dev' or use an environment variable (export SD='--save-dev') and then issue npm install $SD which really doesn't save much typing. – zackse – 2015-02-18T18:57:35.303