1
+ use crate :: internal:: fsx:: PathBufUtf8Ext ;
1
2
use anyhow:: { bail, ensure, Context , Result } ;
2
3
use camino:: { Utf8Path , Utf8PathBuf } ;
3
4
use indoc:: { formatdoc, indoc} ;
@@ -100,11 +101,17 @@ fn mk(
100
101
// Create project directory in case we are called from `new` op.
101
102
fsx:: create_dir_all ( & path) ?;
102
103
103
- init_vcs ( & path, version_control) ?;
104
- write_vcs_ignore ( & path, config, version_control) ?;
104
+ let canonical_path = if let Ok ( canonicalize_path) = fsx:: canonicalize ( & path) {
105
+ canonicalize_path. try_into_utf8 ( ) ?
106
+ } else {
107
+ path
108
+ } ;
109
+
110
+ init_vcs ( & canonical_path, version_control) ?;
111
+ write_vcs_ignore ( & canonical_path, config, version_control) ?;
105
112
106
113
// Create the `Scarb.toml` file.
107
- let manifest_path = path . join ( MANIFEST_FILE_NAME ) ;
114
+ let manifest_path = canonical_path . join ( MANIFEST_FILE_NAME ) ;
108
115
fsx:: write (
109
116
& manifest_path,
110
117
formatdoc ! { r#"
@@ -121,7 +128,7 @@ fn mk(
121
128
122
129
// Create hello world source files (with respective parent directories) if source directory
123
130
// does not exist.
124
- let source_dir = path . join ( DEFAULT_SOURCE_DIR_NAME ) ;
131
+ let source_dir = canonical_path . join ( DEFAULT_SOURCE_DIR_NAME ) ;
125
132
if !source_dir. exists ( ) {
126
133
fsx:: create_dir_all ( & source_dir) ?;
127
134
0 commit comments