{"id":13550185,"url":"https://github.com/flosse/sloc","last_synced_at":"2025-05-13T22:09:20.086Z","repository":{"id":4103967,"uuid":"5213101","full_name":"flosse/sloc","owner":"flosse","description":"simple tool to count SLOC (source lines of code)","archived":false,"fork":false,"pushed_at":"2025-04-07T15:05:14.000Z","size":289,"stargazers_count":955,"open_issues_count":39,"forks_count":83,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-04-27T04:02:31.272Z","etag":null,"topics":["count","javascript","metrics","nodejs","source-code","unmaintained"],"latest_commit_sha":null,"homepage":null,"language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flosse.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-07-28T08:27:12.000Z","updated_at":"2025-04-24T11:03:16.000Z","dependencies_parsed_at":"2023-07-05T18:49:20.624Z","dependency_job_id":"c9d4a4d6-1e17-47ec-8f13-cff6d8889f78","html_url":"https://github.com/flosse/sloc","commit_stats":{"total_commits":247,"total_committers":51,"mean_commits":"4.8431372549019605","dds":0.4008097165991903,"last_synced_commit":"d1857b34190935dabde06b3e5471722c927e67a6"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flosse%2Fsloc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flosse%2Fsloc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flosse%2Fsloc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flosse%2Fsloc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flosse","download_url":"https://codeload.github.com/flosse/sloc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251284326,"owners_count":21564612,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["count","javascript","metrics","nodejs","source-code","unmaintained"],"created_at":"2024-08-01T12:01:29.906Z","updated_at":"2025-04-29T18:18:21.665Z","avatar_url":"https://github.com/flosse.png","language":"CoffeeScript","readme":"# sloc\n\nCreate stats of your source code:\n\n- physical lines\n- lines of code (source)\n- lines with comments\n- lines with single-line comments\n- lines with block comments\n- lines mixed up with source and comments\n- empty lines within block comments\n- empty lines\n- lines with TODO's\n\n[![NPM version](https://badge.fury.io/js/sloc.svg)](http://badge.fury.io/js/sloc)\n[![License](https://img.shields.io/npm/l/sloc.svg)](https://github.com/flosse/sloc/blob/master/LICENCE.txt)\n[![Minified size](http://img.shields.io/badge/size-6,1K-blue.svg)](https://github.com/flosse/sloc)\n\n## Supported outputs\n\nIn addition to the default terminal output (see examples below), sloc provides an alternative set of output formatters:\n\n- CSV\n- JSON\n- Command line table\n\n## Install\n\nTo use sloc as an application install it globally:\n\n```shell\nsudo npm install -g sloc\n```\n\nIf you're going to use it as a Node.js module within your project:\n\n```shell\nnpm install --save sloc\n```\n\n### Browser\n\nYou can also use sloc within your browser application.\n\nLink `sloc.js` in your HTML file:\n\n```html\n\u003cscript src=\"lib/sloc.js\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\n### CLI\n\n```shell\nsloc [option] \u003cfile\u003e|\u003cdirectory\u003e\n```\n\nOptions:\n\n```shell\n-h, --help                  output usage information\n-V, --version               output the version number\n-e, --exclude \u003cregex\u003e       regular expression to exclude files and folders\n-i, --include \u003cregex\u003e       regular expression to include files and folders\n-f, --format \u003cformat\u003e       format output: json, csv, cli-table\n    --format-option [value] add formatter option\n-k, --keys \u003ckeys\u003e           report only numbers of the given keys\n-d, --details               report stats of each analyzed file\n-a, --alias \u003ccustom ext\u003e=\u003cstandard ext\u003e alias custom ext to act like standard ext (eg. php5=php,less=css)\n```\n\ne.g.:\n\n```shell\n$ sloc src/\n\n---------- Result ------------\n\n            Physical :  1202\n              Source :  751\n             Comment :  322\n Single-line comment :  299\n       Block comment :  23\n               Mixed :  116\n               Empty :  245\n\nNumber of files read :  10\n\n------------------------------\n```\n\nor\n\n```shell\n$ sloc --details \\\n       --format cli-table \\\n       --keys total,source,comment \\\n       --exclude i18n*.\\.coffee \\\n       --format-option no-head src/\n\n┌─────────────────────────────────┬──────────┬────────┬─────────┐\n│ src/cli.coffee                  │ 98       │ 74     │ 7       │\n├─────────────────────────────────┼──────────┼────────┼─────────┤\n│ src/helpers.coffee              │ 26       │ 20     │ 0       │\n├─────────────────────────────────┼──────────┼────────┼─────────┤\n│ src/sloc.coffee                 │ 196      │ 142    │ 20      │\n├─────────────────────────────────┼──────────┼────────┼─────────┤\n│ src/formatters/simple.coffee    │ 44       │ 28     │ 7       │\n├─────────────────────────────────┼──────────┼────────┼─────────┤\n│ src/formatters/csv.coffee       │ 25       │ 14     │ 5       │\n├─────────────────────────────────┼──────────┼────────┼─────────┤\n│ src/formatters/cli-table.coffee │ 22       │ 13     │ 0       │\n└─────────────────────────────────┴──────────┴────────┴─────────┘\n```\n\n### Node.js\n\nOr use it in your own node module\n\n```javascript\nvar fs    = require('fs');\nvar sloc  = require('sloc');\n\nfs.readFile(\"mySourceFile.coffee\", \"utf8\", function(err, code){\n\n  if(err){ console.error(err); }\n  else{\n    var stats = sloc(code,\"coffee\");\n    for(i in sloc.keys){\n      var k = sloc.keys[i];\n      console.log(k + \" : \" + stats[k]);\n    }\n  }\n});\n```\n\n### Browser usage\n\n```javascript\nvar sourceCode = \"foo();\\n /* bar */\\n baz();\";\n\nvar stats = window.sloc(sourceCode,\"javascript\");\n```\n\n### Contribute an new formatter\n\n1. Fork this repo\n\n2. add the new formatter into `src/formatters/` that exports a\n   method with three arguments:\n   1. results (object)\n   2. global options (object)\n   3. formatter specific options (array)\n\n3. add the formatter in `src/cli.coffee`\n\n4. open a pull request\n\n### sloc adapters\n\n- Grunt\n  - [grunt-sloc](https://github.com/rhiokim/grunt-sloc).\n  - [grunt-sloccount](https://github.com/asciidisco/grunt-sloccount)\n  - [grunt-maxlines](https://github.com/zerok/grunt-maxlines)\n  - [grunt-file-sloc](https://github.com/bubkoo/grunt-file-sloc)\n\n- Gulp\n  - [gulp-sloc](https://github.com/oddjobsman/gulp-sloc):\n  - [gulp-sloc2](https://github.com/pnarielwala/gulp-sloc2)\n\n- [Atom](https://atom.io/)\n\n  - [atom-sloc](https://github.com/sgade/atom-sloc)\n  - [line-count](https://github.com/mark-hahn/line-count)\n\n- Jenkins\n  - [sloc-for-jenkins](https://www.npmjs.com/package/sloc-for-jenkins)\n  - [sloccount](https://github.com/asciidisco/sloccount)\n\n- Istanbul\n  - [istanbul-reporter-clover-limits](https://github.com/Cellarise/istanbul-reporter-clover-limits/)\n\n- Codemetrics\n  - [codemetrics-process-sloc](https://github.com/maxdow/codemetrics-process-sloc)\n\n## Supported languages\n\n- Assembly\n- Agda\n- Brightscript\n- C / C++\n- C#\n- Clojure / ClojureScript\n- CoffeeScript / IcedCoffeeScript\n- Crystal\n- CSS / SCSS / SASS / LESS / Stylus\n- Dart\n- Elixir \n- Erlang\n- F#\n- Fortran\n- Go\n- Groovy\n- Handlebars\n- Haskell\n- Haxe\n- Hilbert\n- HTML\n- hy\n- Jade\n- Java\n- JavaScript\n- JSX\n- Julia\n- Kotlin\n- LaTeX\n- LilyPond\n- LiveScript\n- Lua\n- MJS\n- Mochi\n- Monkey\n- Mustache\n- Nim\n- Nix\n- Objective-C / Objective-C++\n- OCaml\n- Perl 5\n- PHP\n- PRQL\n- Pug\n- Python\n- R\n- Racket\n- Ren'Py\n- Ruby\n- Rust\n- Scala\n- Squirrel\n- SVG\n- Swift\n- Typescript\n- Visual Basic\n- XML\n- Yaml\n- Zig\n- VHDL\n- Verilog\n- SystemVerilog\n\n## Run tests\n\n```shell\nnpm test\n```\n\n## Build\n\n```shell\nnpm run prepublish\n```\n\n## Changelog\n\nsee `CHANGELOG.md`\n\n## License\n\nsloc is licensed under the MIT license\n","funding_links":[],"categories":["CoffeeScript","nodejs"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflosse%2Fsloc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflosse%2Fsloc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflosse%2Fsloc/lists"}