-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: changed error detection from stderr to command return code to pr…
…event yarn warnings from crashing license-auditor process
- Loading branch information
1 parent
368b25f
commit 7c95390
Showing
7 changed files
with
85 additions
and
30 deletions.
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
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
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
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
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ import * as fs from "node:fs/promises"; | |
import * as path from "node:path"; | ||
import type { JsonResults } from "@license-auditor/data"; | ||
import { describe, expect } from "vitest"; | ||
import { yarnFixture } from "../fixtures"; | ||
import { yarnFixture, yarnWithInvalidGithubDepFixture } from "../fixtures"; | ||
import { addToPackageJson } from "../utils/add-to-package-json"; | ||
import { getCliPath } from "../utils/get-cli-path"; | ||
import { readJsonFile } from "../utils/read-json-file"; | ||
|
@@ -24,13 +24,13 @@ describe("yarn", () => { | |
cwd: testDirectory, | ||
}); | ||
|
||
expect(errorCode).toBe(0); | ||
expect(output).toContain("160 licenses are compliant"); | ||
|
||
const jsonOutput: JsonResults = await readJsonFile( | ||
path.join(testDirectory, "license-auditor.results.json"), | ||
); | ||
|
||
expect(errorCode).toBe(0); | ||
expect(output).toContain("160 licenses are compliant"); | ||
|
||
const addedPackage = jsonOutput.whitelist.find( | ||
(result) => result.packageName === "[email protected]", | ||
); | ||
|
@@ -53,13 +53,13 @@ describe("yarn", () => { | |
cwd: testDirectory, | ||
}); | ||
|
||
expect(errorCode).toBe(0); | ||
expect(output).toContain("160 licenses are compliant"); | ||
|
||
const jsonOutput: JsonResults = await readJsonFile( | ||
path.join(testDirectory, "license-auditor.results.json"), | ||
); | ||
|
||
expect(errorCode).toBe(0); | ||
expect(output).toContain("160 licenses are compliant"); | ||
|
||
const addedPackage = jsonOutput.whitelist.find( | ||
(result) => result.packageName === "[email protected]", | ||
); | ||
|
@@ -82,13 +82,13 @@ describe("yarn", () => { | |
cwd: testDirectory, | ||
}); | ||
|
||
expect(errorCode).toBe(0); | ||
expect(output).toContain("160 licenses are compliant"); | ||
|
||
const jsonOutput: JsonResults = await readJsonFile( | ||
path.join(testDirectory, "license-auditor.results.json"), | ||
); | ||
|
||
expect(errorCode).toBe(0); | ||
expect(output).toContain("160 licenses are compliant"); | ||
|
||
const addedPackage = jsonOutput.whitelist.find( | ||
(result) => result.packageName === "[email protected]", | ||
); | ||
|
@@ -111,13 +111,13 @@ describe("yarn", () => { | |
cwd: testDirectory, | ||
}); | ||
|
||
expect(errorCode).toBe(0); | ||
expect(output).toContain("160 licenses are compliant"); | ||
|
||
const jsonOutput: JsonResults = await readJsonFile( | ||
path.join(testDirectory, "license-auditor.results.json"), | ||
); | ||
|
||
expect(errorCode).toBe(0); | ||
expect(output).toContain("160 licenses are compliant"); | ||
|
||
const addedPackage = jsonOutput.whitelist.find( | ||
(result) => result.packageName === "[email protected]", | ||
); | ||
|
@@ -147,13 +147,13 @@ describe("yarn", () => { | |
cwd: testDirectory, | ||
}); | ||
|
||
expect(errorCode).toBe(0); | ||
expect(output).toContain("160 licenses are compliant"); | ||
|
||
const jsonOutput: JsonResults = await readJsonFile( | ||
path.join(testDirectory, "license-auditor.results.json"), | ||
); | ||
|
||
expect(errorCode).toBe(0); | ||
expect(output).toContain("160 licenses are compliant"); | ||
|
||
const addedPackage = jsonOutput.whitelist.find( | ||
(result) => result.packageName === "[email protected]", | ||
); | ||
|
@@ -189,13 +189,13 @@ describe("yarn", () => { | |
cwd: testDirectory, | ||
}); | ||
|
||
expect(errorCode).toBe(0); | ||
expect(output).toContain("160 licenses are compliant"); | ||
|
||
const jsonOutput: JsonResults = await readJsonFile( | ||
path.join(testDirectory, "license-auditor.results.json"), | ||
); | ||
|
||
expect(errorCode).toBe(0); | ||
expect(output).toContain("160 licenses are compliant"); | ||
|
||
const addedPackage = jsonOutput.whitelist.find( | ||
(result) => result.packageName === "[email protected]", | ||
); | ||
|
@@ -220,13 +220,13 @@ describe("yarn", () => { | |
cwd: testDirectory, | ||
}); | ||
|
||
expect(errorCode).toBe(0); | ||
expect(output).toContain("67 licenses are compliant"); | ||
|
||
const jsonOutput: JsonResults = await readJsonFile( | ||
path.join(testDirectory, "license-auditor.results.json"), | ||
); | ||
|
||
expect(errorCode).toBe(0); | ||
expect(output).toContain("67 licenses are compliant"); | ||
|
||
const addedPackage = jsonOutput.whitelist.find( | ||
(result) => result.packageName === "[email protected]", | ||
); | ||
|
@@ -253,13 +253,13 @@ describe("yarn", () => { | |
cwd: testDirectory, | ||
}); | ||
|
||
expect(errorCode).toBe(0); | ||
expect(output).toContain("66 licenses are compliant"); | ||
|
||
const jsonOutput: JsonResults = await readJsonFile( | ||
path.join(testDirectory, "license-auditor.results.json"), | ||
); | ||
|
||
expect(errorCode).toBe(0); | ||
expect(output).toContain("66 licenses are compliant"); | ||
|
||
const addedPackage = jsonOutput.whitelist.find( | ||
(result) => result.packageName === "[email protected]", | ||
); | ||
|
@@ -292,11 +292,24 @@ describe("yarn", () => { | |
cwd: testDirectory, | ||
}); | ||
|
||
expect(errorCode).toBe(1); | ||
expect(output).toContain("Invalid configuration file at"); | ||
expect(output).toContain("Expected array, received string"); | ||
expect(output).toContain("Expected array, received number"); | ||
expect(output).toContain("Expected object, received string"); | ||
}, | ||
); | ||
}); | ||
describe('github dependency with invalid url', () => { | ||
yarnWithInvalidGithubDepFixture('github dependency with invalid url', async ({ testDirectory }) => { | ||
const { output, errorCode } = await runCliCommand({ | ||
command: "npx", | ||
args: [getCliPath()], | ||
cwd: testDirectory, | ||
}); | ||
|
||
expect(errorCode).toBe(0); | ||
expect(output).toContain("1 license is compliant"); | ||
}); | ||
}); | ||
}); |
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,13 @@ | ||
{ | ||
"name": "testproject", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"packageManager": "[email protected]", | ||
"scripts": { | ||
"run": "echo \"Nope\"" | ||
}, | ||
"private": true, | ||
"dependencies": { | ||
"swich": "git+ssh://[email protected]:Lukasz-pluszczewski/swich.git" | ||
} | ||
} |
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,7 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
"swich@git+ssh://[email protected]:Lukasz-pluszczewski/swich.git": | ||
version "1.2.0" | ||
resolved "git+ssh://[email protected]:Lukasz-pluszczewski/swich.git#027b2f0118b15c001d369b56d4f893072c27d901" |