Last active
January 5, 2021 07:43
-
-
Save Raaghu/0f56302ce161a97ae40f8bc3475e4b9c to your computer and use it in GitHub Desktop.
Vercel Private Git Dependecy in NPM
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
const fs = require("fs"); | |
const home = process.env.HOME; | |
const zeitHome = "/vercel"; | |
const configureGit = function (credentials) { | |
console.log("Configuring git credentials for zeit"); | |
credentials.forEach(credential => { | |
fs.appendFileSync( | |
home + "/.git-credentials", | |
"https://" + | |
credential.user + | |
":" + | |
credential.token + | |
"@" + | |
credential.host | |
); | |
}); | |
fs.writeFileSync(home + "/.gitconfig", "[credential]\n helper = store"); | |
}; | |
if (home == zeitHome) { | |
configureGit([ | |
{ | |
user: "<userName>", | |
token: process.env.VERCEL_READ_REPO_TOKEN, | |
host: "github.com" | |
} | |
]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment