Skip to content

Commit

Permalink
Merge pull request #389 from sunng87/fix/dir-source-for-windows
Browse files Browse the repository at this point in the history
Fix dir source for windows
  • Loading branch information
sunng87 committed Oct 24, 2020
2 parents 8b8e179 + 0fd9434 commit 6a8c536
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -21,6 +21,8 @@ matrix:
name: minimal-versions
script:
- cargo -Z minimal-versions build --verbose
- rust: nightly
os: windows

script:
- cargo $TASK --verbose
Expand Down
7 changes: 5 additions & 2 deletions src/registry.rs
Expand Up @@ -18,6 +18,8 @@ use crate::render::{RenderContext, Renderable};
use crate::support::str::{self, StringWriter};
use crate::template::Template;

#[cfg(feature = "dir_source")]
use std::path;
#[cfg(feature = "dir_source")]
use walkdir::{DirEntry, WalkDir};

Expand Down Expand Up @@ -242,7 +244,7 @@ impl<'reg> Registry<'reg> {
{
let dir_path = dir_path.as_ref();

let prefix_len = if dir_path.to_string_lossy().ends_with('/') {
let prefix_len = if dir_path.to_string_lossy().ends_with(path::MAIN_SEPARATOR) {
dir_path.to_string_lossy().len()
} else {
dir_path.to_string_lossy().len() + 1
Expand All @@ -261,7 +263,8 @@ impl<'reg> Registry<'reg> {
let tpl_file_path = entry.path().to_string_lossy();

let tpl_name = &tpl_file_path[prefix_len..tpl_file_path.len() - tpl_extension.len()];
let tpl_canonical_name = tpl_name.replace("\\", "/");
// replace platform path separator with our internal one
let tpl_canonical_name = tpl_name.replace(path::MAIN_SEPARATOR, "/");
self.register_template_file(&tpl_canonical_name, &tpl_path)?;
}

Expand Down

0 comments on commit 6a8c536

Please sign in to comment.