@@ -33,10 +33,6 @@ internal class CopyDeployer
3333 public CopyDeployer ( CopyDeployerOptions options )
3434 {
3535 _options = options ;
36- if ( _options . Summary )
37- _options . Quiet = true ;
38- if ( _options . Quiet )
39- _options . Verbose = false ;
4036 }
4137
4238 public int Execute ( )
@@ -48,17 +44,24 @@ public int Execute()
4844 Quiet ( "Path to copy from is not a valid directory: {0}" , from ) ;
4945 return 2 ;
5046 }
51- if ( ! Directory . Exists ( Path . GetDirectoryName ( to ) ) ) {
47+ if ( ! Directory . Exists ( ParentDir ( to ) ) ) {
5248 Quiet ( "Path to deploy into is not a valid directory: {0}" , to ) ;
5349 return 3 ;
5450 }
55- Quiet ( "Deploying from {0} into {1}" , from , to ) ;
56- if ( _options . CleanTarget && Directory . Exists ( to ) ) {
57- Quiet ( "Removing previous content at: {0}" , to ) ;
58- Directory . Delete ( to , true ) ;
51+ if ( _options . DontOverWrite && Directory . Exists ( to ) ) {
52+ Summary ( "Skipping existing target directory: {0}" , to ) ;
53+ } else {
54+ Quiet ( "Deploying from {0} into {1}" , from , to ) ;
55+ if ( _options . CleanTarget && Directory . Exists ( to ) ) {
56+ Quiet ( "Removing previous content at: {0}" , to ) ;
57+ Directory . Delete ( to , true ) ;
58+ }
59+ DeployDir ( from , to ) ;
60+ if ( _options . CleanTarget )
61+ Summary ( "{0} files copied" , _filesCopied ) ;
62+ else
63+ Summary ( "{0} files copied, {1} files skipped" , _filesCopied , _filesSkipped ) ;
5964 }
60- DeployDir ( from , to ) ;
61- Summary ( "{0} files copied, {1} files skipped" , _filesCopied , _filesSkipped ) ;
6265 return 0 ;
6366 } catch ( Exception e ) {
6467 Quiet ( "Exception: {0}" , e ) ;
@@ -70,6 +73,11 @@ public int Execute()
7073 private int _filesSkipped = 0 ;
7174 private CopyDeployerOptions _options ;
7275
76+ private static string ParentDir ( string to )
77+ {
78+ return Path . GetDirectoryName ( to ) ;
79+ }
80+
7381 private void DeployDir ( string from , string to )
7482 {
7583 if ( ! Directory . Exists ( to ) )
@@ -105,22 +113,22 @@ private byte[] HashFile(string file)
105113 return md5 . ComputeHash ( stream ) ;
106114 }
107115
108- private void Summary ( string format , params object [ ] parameters )
116+ private void Quiet ( string format , params object [ ] parameters )
109117 {
110- WriteLine ( _options . Summary || ! _options . Quiet , format , parameters ) ;
118+ WriteLineIf ( ! _options . Quiet , format , parameters ) ;
111119 }
112120
113- private void Quiet ( string format , params object [ ] parameters )
121+ private void Summary ( string format , params object [ ] parameters )
114122 {
115- WriteLine ( ! _options . Quiet , format , parameters ) ;
123+ WriteLineIf ( _options . Summary || ! _options . Quiet , format , parameters ) ;
116124 }
117125
118126 private void Verbose ( string format , params object [ ] parameters )
119127 {
120- WriteLine ( _options . Verbose , format , parameters ) ;
128+ WriteLineIf ( _options . Verbose , format , parameters ) ;
121129 }
122130
123- private void WriteLine ( bool condition , string format , object [ ] parameters )
131+ private void WriteLineIf ( bool condition , string format , object [ ] parameters )
124132 {
125133 if ( condition )
126134 Console . WriteLine ( string . Format ( format , parameters ) ) ;
0 commit comments