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