Skip to content

Commit 5ceabdc

Browse files
committed
[TASK] add ability to create .env file with real access key if available
1 parent f2f5f86 commit 5ceabdc

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

lib/cmd/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ async function initGithubRepoBasedOnTemplate (data) {
9494
}
9595
if (data.prompts?.githubRepoFromTmpl?.newRepoName && data.prompts?.githubRepoFromTmpl?.newRepoOwner && data.prompts?.githubRepoFromTmpl.projectName) {
9696
await gitClone(data.prompts.githubRepoFromTmpl.newRepoOwner, data.prompts.githubRepoFromTmpl.newRepoName)
97-
await addDotEnvFile(data.cwd.path, data.prompts.githubRepoFromTmpl.newRepoName, data.prompts.githubRepoFromTmpl.projectName)
97+
await addDotEnvFile(data.cwd.path, data.prompts.githubRepoFromTmpl.newRepoName, data.prompts.githubRepoFromTmpl.projectName, data.prompts.githubRepoFromTmpl.repoSecrets?.hubspotPersonalAccessKey)
9898
}
9999
}
100100
}

lib/utils/fs.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ async function removePath (path) {
8989
* @param {string} cwd - current working directory
9090
* @param {string} destination - destination path
9191
* @param {string} portalname - portal name
92+
* @param {string} [accessKey] - access key
9293
* @returns undefined
9394
*/
94-
async function addDotEnvFile (cwd, destination, portalname) {
95+
async function addDotEnvFile (cwd, destination, portalname, accessKey) {
9596
if (cwd !== '') {
9697
cwd = `${cwd}/`
9798
}
@@ -100,7 +101,10 @@ async function addDotEnvFile (cwd, destination, portalname) {
100101
}
101102
if (!await isFileDirExists(`${cwd}${destination}.env`)) {
102103
try {
103-
await fsPromises.appendFile(`${cwd}${destination}.env`, `hub_${portalname}=personal-access-key-for-${portalname}`)
104+
if (!accessKey) {
105+
accessKey = `personal-access-key-for-${portalname}`
106+
}
107+
await fsPromises.appendFile(`${cwd}${destination}.env`, `hub_${portalname}=${accessKey}`)
104108
} catch (error) {
105109
console.error(error)
106110
}

0 commit comments

Comments
 (0)