mirror of
https://github.com/yewprint/yewprint
synced 2024-11-22 03:23:03 +00:00
yewprint-css: use AsRef<Path> in argument
This commit is contained in:
parent
332c06d2a6
commit
382f7c1e7e
1 changed files with 9 additions and 2 deletions
|
@ -3,7 +3,7 @@ use serde::Deserialize;
|
|||
use std::path::Path;
|
||||
|
||||
/// Download the CSS of Blueprint to a provided destination path.
|
||||
pub fn download_css(dest: &Path) -> Result<()> {
|
||||
pub fn download_css(dest: impl AsRef<Path>) -> Result<()> {
|
||||
let version = download_from_npm_package(
|
||||
"@blueprintjs/core",
|
||||
Path::new("package/lib/css/blueprint.css"),
|
||||
|
@ -15,9 +15,16 @@ pub fn download_css(dest: &Path) -> Result<()> {
|
|||
}
|
||||
|
||||
/// Download any file from NPM package's latest version.
|
||||
pub fn download_from_npm_package(package_name: &str, src: &Path, dest: &Path) -> Result<String> {
|
||||
pub fn download_from_npm_package(
|
||||
package_name: &str,
|
||||
src: impl AsRef<Path>,
|
||||
dest: impl AsRef<Path>,
|
||||
) -> Result<String> {
|
||||
use std::ops::Deref;
|
||||
|
||||
let src = src.as_ref();
|
||||
let dest = dest.as_ref();
|
||||
|
||||
let info = reqwest::blocking::get(format!("https://registry.npmjs.org/{}", package_name))?
|
||||
.json::<PackageInfo>()?;
|
||||
|
||||
|
|
Loading…
Reference in a new issue