Use let instead of var, fix failing test.
This commit is contained in:
@@ -2,7 +2,7 @@ import { expect, test } from '@jest/globals'
|
||||
import { readConfigFile } from '../src/config'
|
||||
|
||||
test('reads the config file', async () => {
|
||||
var options = readConfigFile("./__tests__/fixtures/config-allow-sample.yml")
|
||||
let options = readConfigFile("./__tests__/fixtures/config-allow-sample.yml")
|
||||
expect(options.fail_on_severity).toEqual('critical')
|
||||
expect(options.allow_licenses).toEqual(['BSD', 'GPL 2'])
|
||||
})
|
||||
@@ -16,7 +16,7 @@ test('the default config path handles .yml and .yaml', async () => {
|
||||
})
|
||||
|
||||
test('returns a default config when the config file was not found', async () => {
|
||||
var options = readConfigFile("fixtures/i-dont-exist")
|
||||
expect(options.fail_on_severity).toEqual('all')
|
||||
let options = readConfigFile("fixtures/i-dont-exist")
|
||||
expect(options.fail_on_severity).toEqual('low')
|
||||
expect(options.allow_licenses).toEqual(['all'])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -47,8 +47,8 @@ let rubyChange: Change = {
|
||||
}
|
||||
|
||||
test('it properly filters changes by severity', async () => {
|
||||
let changes: Changes = [npmChange, rubyChange]
|
||||
const expectedChanges: Changes = [npmChange]
|
||||
let changes = [npmChange, rubyChange]
|
||||
const expectedChanges = [npmChange]
|
||||
changes = filterChangesBySeverity('high', changes)
|
||||
expect(changes).toEqual(expectedChanges)
|
||||
})
|
||||
|
||||
5
dist/index.js
generated
vendored
5
dist/index.js
generated
vendored
@@ -13627,13 +13627,14 @@ exports.SEVERITIES = ["critical", "high", "moderate", "low"];
|
||||
exports.CONFIG_FILEPATH = "./.github/dep-review.yml";
|
||||
function readConfigFile(filePath = exports.CONFIG_FILEPATH) {
|
||||
// By default we want to fail on all severities and allow all licenses.
|
||||
var defaultOptions = {
|
||||
const defaultOptions = {
|
||||
fail_on_severity: "low",
|
||||
allow_licenses: ['all'],
|
||||
deny_licenses: []
|
||||
};
|
||||
let data;
|
||||
try {
|
||||
var data = fs.readFileSync(path_1.default.resolve(filePath), "utf-8");
|
||||
data = fs.readFileSync(path_1.default.resolve(filePath), "utf-8");
|
||||
}
|
||||
catch (error) {
|
||||
if (error.code && error.code === 'ENOENT') {
|
||||
|
||||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@@ -16,14 +16,16 @@ type ConfigurationOptions = {
|
||||
|
||||
export function readConfigFile(filePath: string = CONFIG_FILEPATH): ConfigurationOptions {
|
||||
// By default we want to fail on all severities and allow all licenses.
|
||||
var defaultOptions: ConfigurationOptions = {
|
||||
const defaultOptions: ConfigurationOptions = {
|
||||
fail_on_severity: "low",
|
||||
allow_licenses: ['all'],
|
||||
deny_licenses: []
|
||||
}
|
||||
|
||||
let data
|
||||
|
||||
try {
|
||||
var data = fs.readFileSync(path.resolve(filePath), "utf-8");
|
||||
data = fs.readFileSync(path.resolve(filePath), "utf-8");
|
||||
} catch (error: any) {
|
||||
if (error.code && error.code === 'ENOENT') {
|
||||
return defaultOptions
|
||||
|
||||
Reference in New Issue
Block a user