rhiokim / grunt-sloc Goto Github PK
View Code? Open in Web Editor NEWSource line of codes plugin for Grunt.js
License: MIT License
Source line of codes plugin for Grunt.js
License: MIT License
sloc: {
ui: {
options: {
reportDetail: true,
},
files: {
'.': ['catalogs/src/**/*.*']
}
}
}
always returns 0 files
however if I do
files: {
'catalogs/src': ['**]
}
this works
what am i missing?
If I have a filter for '**.styl' files, your code fails because the counter for the fallback extension js
has not been initialized.
You need to move the code initializing the counter one block down (to have it after the ext = 'js'
piece of code).
Thanks, Dom
grunt sloc
seems to be ignoring many files which are included in the src pattern.
To be more specific, here's my sloc config:
sloc: {
'mylib': {
files: {
'mylib': ['*.js']
}
}
}
and here's my directory structure:
mylib/
mylib/one.js
mylib/two.js
mylib/util
mylib/util/three.js
number of files read by grunt sloc
is zero. It should have been 2 files.
The problem does not occur after commenting out these lines related to solving issue #14:
#14 negate match
if (grunt.file.match(srcFilters, [f]).length === 0) {
return;
}
In the above code, f
is an absolute path which seems to be the reason of the problem. One solution would have been to replace the above if
condition with something like:
var relPath = path.relative(path.join(process.cwd(), dest), f);
if (grunt.file.match(srcFilters, [relPath ]).length === 0) {
However after doing the above fix, src patterns such as **.js
do not work.
I would think that instead of using readDir.readSync
grunt's files.src.filter
would do a better job. If you'd like to try this way, I can try to send a PR over the weekend.
Hey I added HTML and CSS support in sloc. Would be great to update grunt-sloc ;-)
https://github.com/rhiokim/grunt-sloc/blob/master/tasks/sloc.js#L16
var AsciiTable = require('ascii-table');
vs
https://github.com/rhiokim/grunt-sloc/blob/master/package.json#L34
"asciitable": "0.0.7"
app
|-- Gruntfile.js
|-- notes.txt
[email protected]
grunt-sloc 0.4.2
grunt-cli v0.1.11
grunt v0.4.2
Mac OS X 10.9.1
'sloc': {
'files': {
'./' : ['*.txt'],
}
},
Upon cd app; grunt 'sloc'
, I only get:
Running "sloc:files" (sloc) task
Done, without errors.
Am I missing something?
There is problem for me with line counting , I'm using OS X Mavericks 10.9.4, grunt-sloc 0.5.2.
And after running task through all files there're just zero's
Running "sloc:main" (sloc) task
Verifying property sloc.main exists in config...OK
Files: scripts/angular/application.js, scripts/angular/config/config.js, scripts/angular/controller/accounts.js, scripts/angular/controller/authentication.js, scripts/angular/controller/cards.js, scripts/angular/controller/controllers.js, scripts/angular/controller/footer.js, scripts/angular/controller/information.js, scripts/angular/controller/information_header.js, scripts/angular/controller/menu_navigation.js, scripts/angular/controller/payments.js, scripts/angular/directive/datePicker.js, scripts/angular/interceptor/responseError.js, scripts/angular/jettap.js, scripts/angular/router/routers.js, scripts/angular/service/authentication.js, scripts/angular/service/services.js, scripts/angular/templates/templates.js -> src
Options: reportType="stdout", reportPath=null, reportDetail, tolerant=false
physical lines 0
lines of source code 0
total comment 0
singleline 0
multiline 0
empty 0
number of files read 0
mode strict
.
|
-|
'
Done, without errors.
Process finished with exit code 0
Using watch then changing a file, sloc doesn't output the results again.
I would like to be able to exclude files from the directories to be parsed. For example, I would like to specify:
css: {
'src/client': [ '**/**.styl', '!**/libs/**' ]
}
You could support them with the following lines added before the call to sloc(source, ext)
:
if (grunt.file.match(srcFilters, [f]).length === 0) {
return;
}
Thanks, Dom
I was looking through the code. I see it supports SASS. Is there any change besides adding an entry for less
in the array to support LESS? If this is the case, can I submit a PR for it?
I am seeing a warning being thrown by grunt after updating the fix to 0.4.1.
Running "sloc:scripts" (sloc) task
Warning: Object -1 has no method 'replace' Use --force to continue.
Fails CI for me!
Directory:
app
|-- gruntfile.js
|-- server.js
In gruntfile.js:
sloc: {
files: {
'./' : [ 'server.js' ],
}
},
Terminal:
grunt sloc
Running "sloc:files" (sloc) task
Done, without errors.
? Windows.
I am using the following, and the output combines the first result (server) into the second report (client), instead of separating the two results.
sloc: {
server: {
files: {
'server': ['**/*.js'],
'./': ['Gruntfile.js', 'server.js']
}
},
client: {
files: {
'client': ['index.html']
}
}
},
OUTPUT:
Running "sloc:server" (sloc) task
physical lines : 221
lines of source code : 152
total comment : 47
singleline : 47
multiline : 0
empty : 22
number of files read : 2
Running "sloc:client" (sloc) task
physical lines : 379
lines of source code : 295
total comment : 47
singleline : 47
multiline : 0
empty : 37
number of files read : 3
sloc: {
client: {
files: {
'client': ['index.html', 'robots.txt', 'js/app/**','views/**']
}
}
}
When I run the following command:
jformDistJson: {
options: {
reportType: 'json',
reportPath: '../doc/sloc/jform-dist-sloc-<%= pkg.version %>.json',
},
files: {
'../js': ['jForm/*.js']
}
}
It produces this output:
Running "sloc:jformDistJson" (sloc) task
Create at: ../doc/sloc/jform-dist-sloc-1.7.1.json
Done, without errors.
I get all 0s in the JSON output:
{
"total": 0,
"source": 0,
"comment": 0,
"single": 0,
"mixed": 0,
"empty": 0,
"block": 0,
"file": 0
}
I am using:
Windows 2008 R2
grunt 0.4.5
grunt-sloc 0.7.1
sloc 0.1.10
node.js 4.4.0
This same relative path works in all of my other grunt tasks. In fact, I've tried seemingly every combination of absolute and relative paths and I get the same result. Can you please help?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.