Skip to content

Commit

Permalink
refactor: merge docs and bar folders into stapler folder
Browse files Browse the repository at this point in the history
  • Loading branch information
maneike committed Nov 25, 2024
1 parent bd3c9c7 commit 30ce5c8
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/core/installMachine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { ActorLogic, AnyEventObject, PromiseSnapshot, and, createActor, createMa

import { InstallMachineContext, StepsCompleted } from '../types';
import { saveStateToRcFile } from '../utils/rcFileManager';
import { prepareDrink } from './installSteps/bar/prepareDrink';
import { createDocFiles } from './installSteps/docs/create';
import { prepareDrink } from './installSteps/stapler/prepareDrink';
import { createDocFiles } from './installSteps/stapler/createDocFiles';
import { initializeRepository } from './installSteps/github/install';
import { pushToGitHub } from './installSteps/github/repositoryManager';
import { modifyHomepage } from './installSteps/homepage/install';
Expand Down
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);
}
});
};

0 comments on commit 30ce5c8

Please sign in to comment.