Files
shiny/tools/updateStrftime.R
Barret Schloerke b4caa9137d Distribute TypeScript code into separate files (#3317)
Co-authored-by: Barret Schloerke <schloerke@gmail.com>
Co-authored-by: Carson Sievert <cpsievert1@gmail.com>
2021-06-09 14:54:47 -04:00

33 lines
929 B
R
Executable File

#!/usr/bin/env Rscript
# This script downloads strftime-min.js from its GitHub repository,
# https://github.com/samsonjs/strftime
# This script can be sourced from RStudio, or run with Rscript.
version <- "0.9.2"
ref <- paste0("v", version)
destdir <- rprojroot::find_package_root_file("inst", "www", "shared", "strftime")
download.file(
paste0("https://raw.githubusercontent.com/samsonjs/strftime/", ref, "/strftime-min.js"),
destfile = file.path(destdir, "strftime-min.js")
)
writeLines(
c(
"# Generated by tools/updateStrftime.R; do not edit by hand",
sprintf('version_strftime <- "%s"', version)
),
rprojroot::find_package_root_file("R", "version_strftime.R")
)
# Update TypeScript installation
withr::with_dir(
rprojroot::find_package_root_file("srcts"),
{
exit_code <- system(paste0("yarn add --dev strftime@", version))
if (exit_code != 0) stop("yarn could not install strftime")
}
)