{"id":15767786,"url":"https://github.com/bubkoo/grunt-file-sloc","last_synced_at":"2025-10-25T22:42:57.860Z","repository":{"id":32748332,"uuid":"36339140","full_name":"bubkoo/grunt-file-sloc","owner":"bubkoo","description":null,"archived":false,"fork":false,"pushed_at":"2016-03-01T05:17:45.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T09:16:59.595Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/bubkoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-27T03:03:24.000Z","updated_at":"2016-03-01T05:17:46.000Z","dependencies_parsed_at":"2022-09-04T14:13:00.676Z","dependency_job_id":null,"html_url":"https://github.com/bubkoo/grunt-file-sloc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubkoo%2Fgrunt-file-sloc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubkoo%2Fgrunt-file-sloc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubkoo%2Fgrunt-file-sloc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubkoo%2Fgrunt-file-sloc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bubkoo","download_url":"https://codeload.github.com/bubkoo/grunt-file-sloc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246458004,"owners_count":20780677,"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":[],"created_at":"2024-10-04T13:41:09.741Z","updated_at":"2025-10-25T22:42:52.819Z","avatar_url":"https://github.com/bubkoo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grunt-file-sloc\n\n\u003e It's SLOC plugin for Grunt.js. Based on [sloc](https://npmjs.org/package/sloc) and fork from [grunt-sloc](https://www.npmjs.com/package/grunt-sloc). Add new feature for `options.alias` to specify ext to act like standard extensions.\n\n## Getting Started\nThis plugin requires Grunt `~0.4.1`\n\nIf you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:\n\n```shell\nnpm install grunt-file-sloc --save-dev\n```\n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks('grunt-file-sloc');\n```\n\n## The \"sloc\" task\n\n### Overview\nIn your project's Gruntfile, add a section named `sloc` to the data object passed into `grunt.initConfig()`.\n\n```js\ngrunt.initConfig({\n  sloc: {\n    options: {\n      // Task-specific options go here.\n    },\n    your_target: {\n      // Target-specific file lists and/or options go here.\n    },\n  },\n})\n```\n\n### Options\n\n#### options.reportType\nType: `String`\nDefault value: `stdout`\n\nIt will generate a JSON file SLOC analysis results. The default value is `stdout`.\nIf we do not specify, in the case of the `stdout`, If you are prompted to enter the `json` and output to the CLI on the json file.\n\n#### options.reportPath\nType: `String`\nDefault value: ``\n\nSpecify the path where you output the JSON file. Create the root folder if you do not specify if.\n\n#### options.reportDetail\nType: `Boolean`\nDefault value: `true`\n\nIf `true`\n\n```shell\n//default reports\n\n//and detail reports\n.-----------------------------------------------------------------------.\n| extension | total | source | comment | single | mixed | empty | block |\n|-----------|-------|--------|---------|--------|-------|-------|-------|\n| js        |    11 |      8 |       2 |      2 |     0 |     1 |     0 |\n| css       |     8 |      7 |       0 |      0 |     0 |     1 |     0 |\n| less      |   235 |    152 |      45 |     30 |     0 |    38 |    15 |\n'-----------------------------------------------------------------------'\n```\n\n#### options.tolerant\nType: `Boolean`\nDefault value: `false`\n\nSet as `false` to analyze only files with a subset of popular extensions.  `true` to analyze files with *any* file extension.  The default is `false`.\n\nIf `true`, the SLOC will be executed on all of the files specified, regardless of file extension.  With 'tolerant' set to `false`, or 'tolerant' unspecified, only supported file extensions will be analyzed.\n\n#### options.alias\nType: `Object`\nDefault value: `null`\n\nCustom ext to act like standard ext.\n\neg.\n\n```js\n{\n  php5: 'php',\n  less: 'css',\n  vm: 'html'\n}\n```\n\n#### options.defaultExt\nType: `String`\nDefault value: `js`\n\nWhen `options.tolerant` is `true`, Specify the default file extension for those files who's extensions are not recognized. \n\n### Usage Examples\n\n#### Basic SLOC\nThis configuration will count line of the input files using the default options.\n\n```js\ngrunt.initConfig({\n  sloc: {\n    // Files Object Format\n    'style1': {\n      files: {\n        'target/path/is/noused': [ 'lib/onlyMyLib.js', 'app/**.js' ],\n        'anystring': [ '*.java', '*.coffee' ]\n      }\n    },\n    \n    // Compact Format\n    'style2': {\n    \tsrc: ['lib/onlyMyLib.js', 'app/**.js', '*.java', '*.coffee']\n    },\n    \n    // Files Array Format\n    'style3': {\n    \tfiles: [\n    \t\t{ src: ['lib/onlyMyLib.js', 'app/**.js'] },\n    \t\t{ src: ['*.java', '*.coffee'] }\n    \t]\n    }\n  }\n})\n```\n\n**result**\n\n```\n...\n\nRunning \"sloc\" (sloc) task\n-------------------------------\n\n        physical lines : 51\n  lines of source code : 29\n         total comment : 6\n            singleline : 6\n             multiline : 0\n                 empty : 16\n\n  number of files read : 12\n                  mode : strict(or torelant) \n                  \n.-----------------------------------------------------------------------.\n| extension | total | source | comment | single | mixed | empty | block |\n|-----------|-------|--------|---------|--------|-------|-------|-------|\n| js        |    11 |      8 |       2 |      2 |     0 |     1 |     0 |\n| css       |     8 |      7 |       0 |      0 |     0 |     1 |     0 |\n| less      |   235 |    152 |      45 |     30 |     0 |    38 |    15 |\n'-----------------------------------------------------------------------'\n\n...\n```\n\n#### Custom Options\n\n\u003c!--\nIn this example, custom options are used to do something else with whatever else. So if the `testing` file has the content `Testing` and the `123` file had the content `1 2 3`, the generated result in this case would be `Testing: 1 2 3 !!!`\n--\u003e\n\n```js\ngrunt.initConfig({\n  sloc: {\n    options: {\n      reportType: 'json',\n      reportPath: 'path/to/sloc-v\u003c%= pkg.version %\u003e.json',\n    },\n    files: {\n        'target/path/is/noused': [ 'lib/onlyMyLib.js', 'app/**.js' ],\n        'anystring': [ '*.java', '*.coffee' ]\n    },\n  },\n})\n```\n\n**result**\n\n```js\n{\n  \"createdAt\": \"2015-03-19T03:35:53.326Z\",\n  \"total\": {\n    \"total\": 5,\n    \"source\": 4,\n    \"comment\": 1,\n    \"single\": 1,\n    \"block\": 0,\n    \"mixed\": 0,\n    \"empty\": 0,\n    \"file\": 3\n  },\n  \"targets\": [\n    \"report_to_json\"\n  ],\n  \"data\": {\n    \"report_to_json\": {\n      \"total\": 5,\n      \"source\": 4,\n      \"comment\": 1,\n      \"single\": 1,\n      \"block\": 0,\n      \"mixed\": 0,\n      \"empty\": 0,\n      \"file\": 3,\n      \"js\": {\n        \"total\": 5,\n        \"source\": 4,\n        \"comment\": 1,\n        \"single\": 1,\n        \"block\": 0,\n        \"mixed\": 0,\n        \"empty\": 0,\n        \"file\": 3\n      },\n      \"createdAt\": \"2015-03-19T03:35:53.326Z\"\n    }\n  }\n}\n```\n\n### Supported Language\n* CoffeeScript\n* C / C++\n* CSS / SCSS -  - Contributor [hsablonniere](https://github.com/hsablonniere)\n* Go\n* HTML - Contributor [hsablonniere](https://github.com/hsablonniere)\n* Java\n* JavaScript\n* Python\n* PHP\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).\n\n## Release History\n\n* 2015-06-25  v0.0.1  fork from [grunt-sloc](https://www.npmjs.com/package/grunt-sloc).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbubkoo%2Fgrunt-file-sloc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbubkoo%2Fgrunt-file-sloc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbubkoo%2Fgrunt-file-sloc/lists"}