inst/templates/init.r

#' @export
grab <- function() {
    box::use(. / install[install])
    init()
    install()
}

#' @export
init <- function() {
    box::use(
        here[here],
        jsonlite[write_json, read_json],
        glue[glue],
        cli[cli_h1, cli_alert, cli_alert_danger, cli_alert_success],
        . / util[scalar]
    )

    module_json <- glue(
        "{here()}/package.json"
    )
    if (!file.exists(module_json)) {
        cli_alert(glue("Creating package.json at '{here()}'."))
        temp <- list(
            name = scalar(""),
            author = scalar(""),
            version = scalar("")
        )
        write_json(temp, module_json, pretty = TRUE)
    } else {
        cli_alert("Init not required, package.json already exists.")
    }
}
ElianHugh/boxingtape documentation built on Feb. 13, 2021, 12:48 a.m.