Exemple #1
0
func RenderFile(inputFile, outDir, rpkgsDir string, keep bool) {
	fmt.Println("Rendering", inputFile)

	if utils.DoesExist(outDir) == false {
		utils.MakeDirs(outDir, 0755)
		log.Println("Created output directory:", outDir)
	}

	extension := filepath.Ext(inputFile)
	switch extension {
	case ".md":
		fmt.Println("Going to render straight up markdown")
		RenderMarkdownFile(inputFile, outDir)
	case ".mkdn":
		fmt.Println("Going to render straight up markdown")
		RenderMarkdownFile(inputFile, outDir)
	case ".markdown":
		fmt.Println("Going to render straight up markdown")
		RenderMarkdownFile(inputFile, outDir)
	case ".Rmd":
		fmt.Println("Going to render RMarkdown")
		RenderRMarkdownFile(inputFile, outDir, rpkgsDir, keep)
	case ".rmd":
		fmt.Println("Going to render RMarkdown")
		RenderRMarkdownFile(inputFile, outDir, rpkgsDir, keep)
	case ".Rmkdn":
		fmt.Println("Going to render RMarkdown")
		RenderRMarkdownFile(inputFile, outDir, rpkgsDir, keep)
	case ".rmkdn":
		fmt.Println("Going to render RMarkdown")
		RenderRMarkdownFile(inputFile, outDir, rpkgsDir, keep)
	case ".Rmarkdown":
		fmt.Println("Going to render RMarkdown")
		RenderRMarkdownFile(inputFile, outDir, rpkgsDir, keep)
	case ".rmarkdown":
		fmt.Println("Going to render RMarkdown")
		RenderRMarkdownFile(inputFile, outDir, rpkgsDir, keep)
	default:
		log.Fatalf("Don't know how to render file of type: '%s'",
			extension,
		)
	}
}
Exemple #2
0
func setupDir(dir string) {
	if utils.DoesExist(dir) == false {
		log.Printf("Creating directory: %s", dir)
		utils.MakeDirs(dir, 0755)
	}

	log.Printf("Setting R_LIBS to: %s", dir)
	if err := os.Setenv("R_LIBS", dir); err != nil {
		log.Fatalf(
			"Could not set R_LIBS: %s",
			err,
		)
	}

	Rlibs := os.Getenv("R_LIBS")
	if Rlibs != dir {
		log.Fatalln(
			"Environment Variable 'R_LIBS' isn't correctly set.  ",
		)
	}
}