Example #1
0
function editFile(type, pathToFile, string, options) {
  let fileContent = fs.readFileSync(pathToFile, {encoding: 'utf-8'});
  let updatedContent;

  if (type === 'insert') {
    updatedContent = editer.insert(string, fileContent, options);
  } else if (type === 'remove') {
    updatedContent = editer.remove(string, fileContent, options);
  }

  fs.writeFileSync(pathToFile, updatedContent);
}
Example #2
0
export function writeToFile(pathToFile, string, options) {
  let fileContent = fs.readFileSync(pathToFile, {encoding: 'utf-8'});
  let updatedContent = editer.insert(string, fileContent, options);

  fs.writeFileSync(pathToFile, updatedContent);
}