-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: merge docs and bar folders into stapler folder
- Loading branch information
Showing
4 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
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
File renamed without changes.
34 changes: 34 additions & 0 deletions
34
packages/core/installMachine/installSteps/stapler/modifyGitignore.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import { logger } from '../../../utils/logger'; | ||
import { promisify } from 'util'; | ||
|
||
const readFileAsync = promisify(fs.readFile); | ||
const writeFileAsync = promisify(fs.writeFile); | ||
|
||
export const modifyGitignore = async (entry: string) => { | ||
await logger.withSpinner('stapler', `Adding ${entry} to .gitignore..`, async (spinner) => { | ||
const gitignorePath = path.join(process.cwd(), '.gitignore'); | ||
|
||
try { | ||
// Read the .gitignore file | ||
const data = await readFileAsync(gitignorePath, 'utf8'); | ||
|
||
// Check if the entry is already listed | ||
if (!data.includes(entry)) { | ||
// Append the entry at the end of the file | ||
const updatedData = `${data.trim()}\n${entry}\n`; | ||
|
||
// Write the updated .gitignore back to the file | ||
await writeFileAsync(gitignorePath, updatedData); | ||
|
||
spinner.succeed(`${entry} added to .gitignore.`); | ||
} else { | ||
spinner.info(`${entry} is already listed in .gitignore.`); | ||
} | ||
} catch (err) { | ||
spinner.fail('Failed to update .gitignore'); | ||
console.error('Error:', err); | ||
} | ||
}); | ||
}; |
File renamed without changes.