Skip to content

Instantly share code, notes, and snippets.

@Raaghu
Last active January 5, 2021 07:43
Show Gist options
  • Save Raaghu/0f56302ce161a97ae40f8bc3475e4b9c to your computer and use it in GitHub Desktop.
Save Raaghu/0f56302ce161a97ae40f8bc3475e4b9c to your computer and use it in GitHub Desktop.
Vercel Private Git Dependecy in NPM
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