Skip to content
This repository
Browse code

Clean up

  • Loading branch information...
commit 30a3ddfd6add8dae9e036ff7e38654a6714424b7 1 parent a569f76
Garen Torikian gjtorikian authored

Showing 2 changed files with 16 additions and 10 deletions. Show diff stats Hide diff stats

  1. +15 9 lib/DAV/plugins/codesearch.js
  2. +1 1  lib/jsdav.js
24 lib/DAV/plugins/codesearch.js
@@ -190,7 +190,8 @@ var prevFile;
190 190 }
191 191
192 192 if (Util.isTrue(options.wholeword))
193   - cmd += " -w"
  193 + cmd += " -w";
  194 +
194 195 var query = options.query;
195 196 // grep has a funny way of handling new lines (that is to say, it's non-existent)
196 197 // if we're not doing a regex search, then we must split everything between the
@@ -228,9 +229,8 @@ var prevFile;
228 229 " if s/" + query + "/" + options.replacement + "/mg" + ( !Util.isTrue(options.casesensitive) ? "i" : "" ) + ";'"
229 230 }
230 231
231   - if (jsDAV.debugMode) {
232   - Util.log("search command: " + cmd);
233   - }
  232 + if (jsDAV.debugMode)
  233 + Util.log("search command: " + cmd);
234 234
235 235 try {
236 236 this.grep = Spawn("/bin/bash", ["-c", cmd]);
@@ -248,19 +248,25 @@ var prevFile;
248 248 this.grep.stdout.on("data", function(data) {
249 249 if (!Util.empty(data)) {
250 250 buffer += data;
251   - count += self.parseSearchResult(data, node.path, options, prevFile, cbwrite);
252   - buffer = '';
  251 + if (data.indexOf("\n") !== -1) {
  252 + if (jsDAV.debugMode)
  253 + Util.log(data);
  254 + count += self.parseSearchResult(data, node.path, options, prevFile, cbwrite);
  255 + buffer = '';
  256 + }
253 257 }
254 258 });
255 259 this.grep.stderr.on("data", function(data) {
256 260 if (!Util.empty(data)) {
257 261 buffer += data;
258   - count += self.parseSearchResult(data, node.path, options, prevFile, cbwrite);
259   - buffer = '';
  262 + if(data.indexOf("\n") !== -1) {
  263 + count += self.parseSearchResult(data, node.path, options, prevFile, cbwrite);
  264 + buffer = '';
  265 + }
260 266 }
261 267 });
262 268 this.grep.on("exit", function(code, signal) {
263   - cbend(null, '\nResults: {"count": '+ count + ', "filecount":' + filecount + '}');
  269 + cbend(null, '\nResults: {"count": '+ count + ', "filecount":' + filecount + '}\n');
264 270 });
265 271 };
266 272
2  lib/jsdav.js
@@ -7,7 +7,7 @@
7 7 */
8 8 "use strict";
9 9
10   -exports.debugMode = true;
  10 +exports.debugMode = false;
11 11
12 12 exports.__INODE__ = 1 << 2;
13 13 exports.__ICOLLECTION__ = 1 << 3;

0 comments on commit 30a3ddf

Please sign in to comment.
Something went wrong with that request. Please try again.