Utility function to make changes to a source file
gp_change_file( path = system.file("js/src/App.js", package = "geoplumber"), what = " * geoplumber R package code.", pattern = " * geoplumber R package code.", before = TRUE, replace = FALSE, verbose = FALSE )
path | path of file to change, used in readLines() |
---|---|
what | vector to add to path |
pattern | where to add the what to, 1st is used. Unique is best. |
before | s after the pattern |
replace | or replace pattern |
verbose | cat the change out |
{ gp_change_file(replace = TRUE, verbose = TRUE) # replacing the comment itself. }#> [1] "Changed at: 2" #> [1] " * geoplumber R package code." #> [2] " */" #> [3] "import React, { Component } from 'react';" #> [4] "import { Switch, Route } from 'react-router-dom';" #> [5] "" #> [6] "import Welcome from './Welcome';"