Skip to content

Commit

Permalink
feat: add to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
adantoscano committed Oct 10, 2023
1 parent 58f2625 commit 2bf2841
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/services/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as fs from "node:fs";
import checkStringInFile from "./check-string-in-file.js";

/**
* The name of the config file
Expand All @@ -22,14 +23,15 @@ export const TEMP_FOLDER_NAME = ".api-mock-runner";
* @returns {Promise<void>}
*/
export async function addToGitignore(textToAppend) {
// TODO: create function that validates if is already in gitignore
fs.appendFile(`${process.cwd()}/.gitignore`, `\n${textToAppend}`, (err) => {
if (err) {
console.error(err);
} else {
console.log(`${textToAppend} added to .gitignore`);
}
});
if (!checkStringInFile(textToAppend, `${process.cwd()}/.gitignore`)) {
fs.appendFile(`${process.cwd()}/.gitignore`, `\n${textToAppend}`, (err) => {
if (err) {
console.error(err);
} else {
console.log(`${textToAppend} added to .gitignore`);
}
});
}
}
/**
* Verify if the origin is remote
Expand Down

0 comments on commit 2bf2841

Please sign in to comment.