-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added -init arg & auto search for a config.
- Loading branch information
Morgan Dennithorne
committed
Jun 27, 2017
1 parent
68cf71a
commit f7cdd72
Showing
3 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"output" : [ ], | ||
"rule" : [ ], | ||
"excludes" : [ ], | ||
"includes" : [ { } ], | ||
"inheritParent" : false, | ||
"inheritPlugins" : true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,41 @@ | ||
#! /usr/bin/env node | ||
var shell = require("shelljs"); | ||
var findConfig = require('find-config'); | ||
|
||
// Check for the init arg. | ||
var initIndex = process.argv.indexOf("-init"); | ||
if (initIndex !== -1) { | ||
|
||
var fs = require('fs'); | ||
|
||
// Remove -init, it is not part of the official cflint. | ||
process.argv.splice(initIndex); | ||
|
||
// Add version just so it wont output the help. | ||
process.argv.push('-version'); | ||
|
||
// Get the empty configfile data. | ||
var cflintrcData = fs.readFileSync(__dirname + '/../.cflintrc', 'utf8'); | ||
|
||
fs.writeFileSync(process.cwd() + '/.cflintrc', cflintrcData); | ||
|
||
console.log(` | ||
Successfully created .cflintrc file in ${process.cwd()} | ||
By default there are only parsing errors, all other rules are excluded. | ||
Run 'cflint -listrulegroups' to see possible rules. | ||
`) | ||
} | ||
|
||
// Collect the arguments to resend. | ||
var userArgs = process.argv.slice(2).join(" "); | ||
|
||
// Find the path to the nearest config file '.cflintrc'. | ||
var configFilePath = findConfig('.cflintrc'); | ||
|
||
// If there is a config file append it. | ||
if (configFilePath) { | ||
userArgs += ' -configfile ' + configFilePath | ||
} | ||
|
||
// Execute cflint. | ||
shell.exec('java -jar ' + __dirname + '/CFLint-1.0.1-all.jar ' + userArgs); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters