Skip to content
This repository was archived by the owner on Sep 26, 2023. It is now read-only.

Commit 6eeaef1

Browse files
committed
Merge pull request #41 from pose/no-color
Adding --noColor argument.
2 parents 9ebdd4e + 5e11145 commit 6eeaef1

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

bin/shared-options.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,9 @@ module.exports = {
7474
flag: true,
7575
help: "asynchronously read/write files in directory (faster)",
7676
hidden: true
77+
},
78+
noColor: {
79+
help: 'Disable color output.',
80+
flag: true
7781
}
78-
}
82+
};

replace.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,11 @@ module.exports = function(options) {
150150
}
151151

152152
if (!options.silent) {
153-
var printout = file[options.fileColor] || file;
153+
var printout = options.noColor ? file : file[options.fileColor] || file;
154154
if (options.count) {
155-
printout += (" (" + match.length + ")").grey;
155+
var count = " (" + match.length + ")";
156+
count = options.noColor ? count : count.grey;
157+
printout += count;
156158
}
157159
console.log(printout);
158160
}
@@ -167,7 +169,10 @@ module.exports = function(options) {
167169
break;
168170
}
169171
var replacement = options.replacement || "$&";
170-
line = line.replace(regex, replaceFunc || replacement[options.color]);
172+
if (!options.noColor) {
173+
replacement = replacement[options.color];
174+
}
175+
line = line.replace(regex, replaceFunc || replacement);
171176
console.log(" " + (i + 1) + ": " + line.slice(0, limit));
172177
}
173178
}

0 commit comments

Comments
 (0)