File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,17 @@ util = require '../utils'
77eyes = require ' eyes'
88fs = require ' fs'
99
10+ # TODO: make this configurable
11+ # right now, the replacement is hard-coded to replace "hard tabs" with "soft tabs, two spaces"
12+ config = {
13+ tab_identifier : / \t / g ,
14+ tab_replacement : ' '
15+ }
16+
17+
1018exports .exec = (options , callback ) ->
1119 file_count = 0
20+ tab_instances = 0
1221
1322 if options ._ .length == 1
1423 callback ({ message : " File name, directory path, or glob is required" });
@@ -31,12 +40,13 @@ exports.exec = (options, callback) ->
3140 # Process the file's contents and then re-save it
3241 # Regex by Fedor Induty
3342 # I've got to assume there are bugs in this Regex, we made it quickly
34- stripped = data .toString ().replace (/ (^ | \r | \n | \r\n )+ \s + (\r | \n | \r\n | $ )+ / g ,' $1$2' ).replace (/ (\r | \n\n | \r\n\n )+ / g , ' $1' )
43+ tab_instances += data .toString ().split (' \t ' ).length
44+ stripped = data .toString ().replace (config .tab_identifier , config .tab_replacement )
3545
3646 fs .writeFile v, stripped, (err , result ) ->
3747 file_count = file_count - 1
3848 if file_count == 0
39- callback null , ' Stripped '
49+ callback null , { " Tabs Replaced " : tab_instances, " Files Modified " : util . paths (glob). length }
4050
4151 )(v,i)
4252
You can’t perform that action at this time.
0 commit comments