Comparing version 0.1.0 to 0.1.1
@@ -5,2 +5,3 @@ 'use strict'; | ||
const path = require('path'); | ||
const yaml = require('js-yaml'); | ||
const execute = require('../../execute'); | ||
@@ -11,3 +12,3 @@ const options = require('./options'); | ||
execute (argv) { | ||
const config = loadJson(argv.c || argv.config); | ||
const config = loadConfig(argv.c || argv.config); | ||
const opts = options.get(argv); | ||
@@ -38,7 +39,11 @@ return execute.checkRules(config, opts).then(logErrors, console.error); | ||
function loadJson(fileName){ | ||
function loadConfig(fileName){ | ||
const file = path.resolve(process.cwd(), fileName); | ||
let json; | ||
const ext = path.extname(fileName).toLowerCase(); | ||
let cfg; | ||
try { | ||
json = JSON.parse(fs.readFileSync(file, 'utf8')); | ||
const fileStr = fs.readFileSync(file, 'utf8'); | ||
cfg = ext == '.yml' || ext == '.yaml' | ||
? yaml.safeLoad(fileStr) | ||
: JSON.parse(fileStr); | ||
} catch(err) { | ||
@@ -48,3 +53,3 @@ console.error('error: ' + err.message); | ||
} | ||
return json; | ||
return cfg; | ||
} | ||
@@ -51,0 +56,0 @@ |
{ | ||
"name": "gh-lint", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Rule-based command-line tool for auditing GitHub repositories", | ||
@@ -13,2 +13,3 @@ "main": "execute/index.js", | ||
"co": "^4.6.0", | ||
"js-yaml": "^3.8.1", | ||
"minimist": "^1.2.0", | ||
@@ -15,0 +16,0 @@ "request": "^2.79.0", |
@@ -37,2 +37,13 @@ 'use strict'; | ||
it('should check repos with YAML config', () => { | ||
githubMock.mock('/repos/MailOnline/videojs-vast-vpaid', '../fixtures/videojs-vast-vpaid-repo-meta'); | ||
githubMock.mock('/repos/milojs/milo', '../fixtures/milo-repo-meta'); | ||
return ok(run(['check', '-c', './spec/fixtures/config-repos.yml'], false)) | ||
.then(() => { | ||
assert.equal(log, 'warning MailOnline/videojs-vast-vpaid: repo-homepage - not satisfied'); | ||
assert(nock.isDone()); | ||
}); | ||
}); | ||
it('should check repos in orgs', () => { | ||
@@ -39,0 +50,0 @@ githubMock.repos.organization.MailOnline.list(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
720138
98
13107
0
7
+ Addedjs-yaml@^3.8.1
+ Addedargparse@1.0.10(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedjs-yaml@3.14.1(transitive)
+ Addedsprintf-js@1.0.3(transitive)