From 782a360d76b2a46698b5c7effddd7f2a53b18256 Mon Sep 17 00:00:00 2001 From: timelyportfolio Date: Mon, 8 Dec 2014 13:36:34 -0600 Subject: [PATCH 1/3] handle more bower cases with bower install in scaffoldWidget --- R/scaffold.R | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/R/scaffold.R b/R/scaffold.R index 3184d63f..5793d7cf 100644 --- a/R/scaffold.R +++ b/R/scaffold.R @@ -216,6 +216,11 @@ readBower <- function(pkg, src = "inst/htmlwidgets/lib"){ # Get YAML configuration for widget getConfig <- function(pkg, src = "inst/htmlwidgets/lib"){ + # handle bower when in github shorthand or with full git path + # by using basename and removing .git from basename + # see http://bower.io/#install-bower + # "A package can be a GitHub shorthand, a Git endpoint, a URL, and more." + pkg = gsub(basename(pkg),pattern="([.]*)(.git)",replacement="") deps = readBower(pkg, src)$deps all = c(names(deps),pkg) config = lapply(all, function(pkg){ From 268a9a64126d3ef60640ca629285e198fcab06b2 Mon Sep 17 00:00:00 2001 From: timelyportfolio Date: Wed, 24 Dec 2014 13:07:02 -0600 Subject: [PATCH 2/3] fix issue #53 for non-windows with scaffold --- R/scaffold.R | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/R/scaffold.R b/R/scaffold.R index 5793d7cf..3096993b 100644 --- a/R/scaffold.R +++ b/R/scaffold.R @@ -185,15 +185,16 @@ installBowerPkg <- function(pkg){ findBower <- function(){ # a slightly more robust finder of bower for windows # which does not require PATH environment variable to be set - bowerPath = if(Sys.which("bower") == "") { + + # try to find the easy case + bowerPath = Sys.which("bower") + + if(bowerPath == "" && identical(.Platform$OS.type,"windows")) { # if it does not find Sys.which('bower') - # also check APPDATA to see if found there - if(identical(.Platform$OS.type,"windows")) { - Sys.which(file.path(Sys.getenv("APPDATA"),"npm","bower.")) - } - } else { - Sys.which("bower") + # also check APPDATA if Windows to see if found there + bowerPath = Sys.which(file.path(Sys.getenv("APPDATA"),"npm","bower.")) } + return(bowerPath) } From 816dd07e257ab8acc7fe532635408bdda178bf40 Mon Sep 17 00:00:00 2001 From: timelyportfolio Date: Wed, 24 Dec 2014 13:15:53 -0600 Subject: [PATCH 3/3] probably overly robust but check for `NULL` also when looking for bower for scaffold --- R/scaffold.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/scaffold.R b/R/scaffold.R index 3096993b..8fee3c8f 100644 --- a/R/scaffold.R +++ b/R/scaffold.R @@ -157,8 +157,10 @@ addWidgetJS <- function(name, edit){ # This function uses bower to install a javascript package along with # its dependencies. installBowerPkg <- function(pkg){ + bowerPath = findBower() + # check if bower is installed - if (findBower() == ""){ + if (is.null(bowerPath) || bowerPath == ""){ stop( "Please install bower from http://bower.io", call. = FALSE