Skip to content

Commit

Permalink
Merge dbbd636 into bf2ded1
Browse files Browse the repository at this point in the history
  • Loading branch information
sergioramos committed Feb 22, 2016
2 parents bf2ded1 + dbbd636 commit 2679fb3
Show file tree
Hide file tree
Showing 6 changed files with 3,405 additions and 15 deletions.
17 changes: 17 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
engines:
eslint:
enabled: true
config:
config: .eslintrc
fixme:
enabled: true
duplication:
enabled: true
config:
languages:
- javascript
nodesecurity:
enabled: true
exclude_paths:
- test/cases
- examples
31 changes: 23 additions & 8 deletions bin/jsctags
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var format = require('util').format;
var argv = require('optimist').argv;
var jsctags = require('../');
var path = require('path');
var glob = require('glob');
var collect = require('collect-stream');
var async = require('async');
var fs = require('fs');
Expand All @@ -29,16 +30,21 @@ var file = (function () {
return path.resolve(process.cwd(), argv.file);
}

if (argv._.length) {
return argv._.map(function (file) {
return path.resolve(process.cwd(), file);
});
if (!argv._.length && !argv.find) {
return format('///null/%s', Math.floor(Math.random() * 100));
}

return format('///null/%s', Math.floor(Math.random() * 100));
var files = !argv.find ? argv._ : glob.sync(argv.find, {
nosort: true,
silent: true
});

return files.map(function (file) {
return path.resolve(process.cwd(), file);
});
})();

if (!argv._.length) {
if (!argv._.length && !argv.find) {
collect(process.stdin, function (err, content) {
if (err) {
throw err;
Expand Down Expand Up @@ -74,7 +80,7 @@ if (!argv._.length) {
async.map(files, function (file, callback) {
fs.readFile(file, 'utf8', function (err, content) {
if (err) {
return callback(err);
return callback(null, err);
}

jsctags({
Expand All @@ -83,7 +89,7 @@ if (!argv._.length) {
content: content
}, function (err, tags) {
if (err) {
throw err;
return callback(null, err);
}

tags.tagfile = file;
Expand All @@ -99,6 +105,15 @@ if (!argv._.length) {
throw err;
}

results = results.filter(function(res) {
if (res instanceof Error) {
console.error(err);
return false
}

return true;
});

if (argv.f) {
var ctags = Array.prototype.concat.apply([], results.map(jsctags.ctags));
console.log(ctags.join(''));
Expand Down
Loading

0 comments on commit 2679fb3

Please sign in to comment.