-
-
Save yallie/671a230cc57231d88901aaef0f892b2c to your computer and use it in GitHub Desktop.
How to store npm packages in github branches
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#1) Create a new repo named "my-npm" and let github initialize it with a README (screenshot below) | |
#2) Clone it to your computer | |
git clone [email protected]:SmallRoomLabs/my-npm.git | |
#3) Go to the clone and create a new empty branch for the first package | |
cd my-npm | |
git checkout --orphan logger | |
#4) Delete all files in the folder | |
rm -f * | |
#5) Create the files for the new package/branch | |
echo '### THE LOGGER' > README.md | |
echo 'console.log("This is logger");' > logger.js | |
echo -e '{\n"name":"logger",\n"description":"The logger",\n"version":"1.0.0",\n"main":"logger.js",\n"repository":{}\n}' > package.json | |
#6) Add & Commit the files to this branch | |
git add -A . | |
git commit -m "Initial commit for logger" | |
#7) Push the changes to github | |
git push --set-upstream origin logger | |
#8) Repeat this for another package | |
git checkout --orphan crypter | |
rm -f * | |
echo '### THE CRYPTER' > README.md | |
echo 'console.log("This is crypter");' > crypter.js | |
echo -e '{\n"name":"crypter",\n"description":"The crypter",\n"version":"1.0.0",\n"main":"crypter.js",\n"repository":{}\n}' > package.json | |
git add -A . | |
git commit -m "Initial commit for crypter" | |
git push --set-upstream origin crypter | |
#9) Go back to the master branch | |
git checkout master | |
#10) Create a node project using the two new packages | |
echo -e "require('logger');\nrequire('crypter');\n" > mycode.js | |
#11) Create the package.json and add the packages to it | |
echo -e '{"name":"mycode",\n"description":"The mycode",\n"version":"1.0.0",\n"main":"mycode.js",\n"repository":{}\n}' > package.json | |
npm install --save git+ssh://[email protected]:SmallRoomLabs/my-npm.git#logger | |
npm install --save git+ssh://[email protected]:SmallRoomLabs/my-npm.git#crypter | |
#12) Run the node too see if it works | |
node mycode.js | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment