Skip to content

Commit f23aa63

Browse files
authored
Merge pull request #88 from spenserblack/master
Fix compilation errors on Linux and OSX
2 parents 1ba0286 + 0264b7c commit f23aa63

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ bytecount = "0.5.1"
1717
clap = "2.33.0"
1818
strum = "0.16.0"
1919
strum_macros = "0.16.0"
20-
ansi_term = "0.12"
20+
21+
[target.'cfg(windows)'.dependencies]
22+
ansi_term = "0.12"

src/main.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ extern crate colored;
33
extern crate git2;
44
extern crate license;
55
extern crate tokei;
6-
extern crate ansi_term;
76
#[macro_use]
87
extern crate clap;
98
extern crate strum;
109
#[macro_use]
1110
extern crate strum_macros;
1211

12+
#[cfg(target = "windows")]
13+
extern crate ansi_term;
14+
1315
use colored::Color;
1416
use colored::*;
1517
use git2::{Repository, Oid};
@@ -446,9 +448,18 @@ impl fmt::Display for Language {
446448
}
447449

448450
fn main() -> Result<()> {
449-
if cfg!(windows) && !ansi_term::enable_ansi_support().is_ok() {
451+
452+
#[cfg(target = "windows")]
453+
let enabled = ansi_term::enable_ansi_support().is_ok();
454+
455+
#[cfg(not(target = "windows"))]
456+
let enabled = true;
457+
458+
if !enabled {
450459
colored::control::set_override(false);
451460
}
461+
462+
452463
if !is_git_installed() {
453464
return Err(Error::GitNotInstalled);
454465
}

0 commit comments

Comments
 (0)