Skip to content

Instantly share code, notes, and snippets.

@nathanlogan
Last active June 13, 2017 20:00
Show Gist options
  • Save nathanlogan/696811cb695cda26843101a56fe11ece to your computer and use it in GitHub Desktop.
Save nathanlogan/696811cb695cda26843101a56fe11ece to your computer and use it in GitHub Desktop.
An npm one-liner OSX script for npm linking all components in a subdirectory
{
"name": "",
"version": "",
"description": "",
"repository": {},
"scripts": {
"link-one:osx": "cd src/components/ && select fname in */; do (cd $fname && npm link) && break; done && cd ../..",
"link-all:osx": "cd src/components/ && for fname in */; do (cd $fname && npm link); done && cd ../.."
},
"dependencies": {},
"author": "",
"license": "",
"homepage": ""
}
@nathanlogan
Copy link
Author

This assumes your components are in a /src/components directory, but you could, of course, tweak that in the script to your heart's content. The parenthesis (( and )) are important here, as they create a subshell that allows for the cd without affecting the parent script. Other than that, I think it's pretty straightforward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment