Skip to content

Commit

Permalink
Merge pull request #356 from romanzipp/add-option-to-omit-version-number
Browse files Browse the repository at this point in the history
Add configuration option to omit version number from output
  • Loading branch information
tobybessant authored Apr 21, 2024
2 parents 2b2a5e2 + 8c3a45c commit 492cb5c
Show file tree
Hide file tree
Showing 24 changed files with 704 additions and 167 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ E.g. `.glf.json`, `.glfrc.yml`, `.generatelicensefile.jsonc`, `.config/glf.js`,
},

// Exclude any packages from the output.
"exclude": ["my-package@1.2.0"]
"exclude": ["my-package@1.2.0"],

// Omit the version number in the output file
"omitVersion": false
}
```

Expand Down
144 changes: 144 additions & 0 deletions e2e/npm-package/test/cli/__snapshots__/index.e2e.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,78 @@ https://www.npmjs.com/package/generate-license-file
"
`;

exports[`cli for a relative path omit-versions should match snapshot when --omit-versions is given 1`] = `
"This file was generated with the generate-license-file npm package!
https://www.npmjs.com/package/generate-license-file
The following npm package may be included in this product:
- dep-four
This package contains the following license and notice below:
# Dep Four
This license file is spelt \`LICENCE\`.
This license should be found.
-----------
The following npm package may be included in this product:
- dep-one
This package contains the following license and notice below:
# Dep One
This license file is spelt \`LICENSE.md\`.
This license should be found.
-----------
The following npm package may be included in this product:
- dep-three
This package contains the following license and notice below:
# Dep Three
This license file is spelt \`LICENSE\`.
This license should be found.
-----------
The following npm packages may be included in this product:
- dep-two
- dep-two-duplicate
These packages each contain the following license and notice below:
# Dep Two
This license file is spelt \`LICENCE.md\`.
This license should be found.
-----------
The following npm package may be included in this product:
- dep-five
This package contains the following license and notice below:
MIT
-----------
This file was generated with the generate-license-file npm package!
https://www.npmjs.com/package/generate-license-file
"
`;

exports[`cli for a relative path should match snapshot using -i and -o 1`] = `
"This file was generated with the generate-license-file npm package!
https://www.npmjs.com/package/generate-license-file
Expand Down Expand Up @@ -864,6 +936,78 @@ https://www.npmjs.com/package/generate-license-file
"
`;

exports[`cli for an absolute path omit-versions should match snapshot when --omit-versions is given 1`] = `
"This file was generated with the generate-license-file npm package!
https://www.npmjs.com/package/generate-license-file
The following npm package may be included in this product:
- dep-four
This package contains the following license and notice below:
# Dep Four
This license file is spelt \`LICENCE\`.
This license should be found.
-----------
The following npm package may be included in this product:
- dep-one
This package contains the following license and notice below:
# Dep One
This license file is spelt \`LICENSE.md\`.
This license should be found.
-----------
The following npm package may be included in this product:
- dep-three
This package contains the following license and notice below:
# Dep Three
This license file is spelt \`LICENSE\`.
This license should be found.
-----------
The following npm packages may be included in this product:
- dep-two
- dep-two-duplicate
These packages each contain the following license and notice below:
# Dep Two
This license file is spelt \`LICENCE.md\`.
This license should be found.
-----------
The following npm package may be included in this product:
- dep-five
This package contains the following license and notice below:
MIT
-----------
This file was generated with the generate-license-file npm package!
https://www.npmjs.com/package/generate-license-file
"
`;

exports[`cli for an absolute path should match snapshot using -i and -o 1`] = `
"This file was generated with the generate-license-file npm package!
https://www.npmjs.com/package/generate-license-file
Expand Down
11 changes: 11 additions & 0 deletions e2e/npm-package/test/cli/index.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,17 @@ describe("cli", () => {
});
});

describe("omit-versions", () => {
it("should match snapshot when --omit-versions is given", async () => {
await execAsync(
`npx generate-license-file --input ${input} --output ${output} --omit-versions`
);

const result = await fs.readFile(output, "utf8");
expect(result).toMatchSnapshot();
});
});

describe("version", () => {
beforeEach(() => (requiresUnlink = false));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,75 @@ This file was generated with the generate-license-file npm package!
https://www.npmjs.com/package/generate-license-file
"
`;

exports[`generateLicenseFile should omit versions when omitVersions is true 1`] = `
"This file was generated with the generate-license-file npm package!
https://www.npmjs.com/package/generate-license-file
The following npm package may be included in this product:
- dep-four
This package contains the following license and notice below:
# Dep Four
This license file is spelt \`LICENCE\`.
This license should be found.
-----------
The following npm package may be included in this product:
- dep-one
This package contains the following license and notice below:
# Dep One
This license file is spelt \`LICENSE.md\`.
This license should be found.
-----------
The following npm package may be included in this product:
- dep-three
This package contains the following license and notice below:
# Dep Three
This license file is spelt \`LICENSE\`.
This license should be found.
-----------
The following npm packages may be included in this product:
- dep-two
- dep-two-duplicate
These packages each contain the following license and notice below:
# Dep Two
This license file is spelt \`LICENCE.md\`.
This license should be found.
-----------
The following npm package may be included in this product:
- dep-five
This package contains the following license and notice below:
MIT
-----------
This file was generated with the generate-license-file npm package!
https://www.npmjs.com/package/generate-license-file
"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,75 @@ This file was generated with the generate-license-file npm package!
https://www.npmjs.com/package/generate-license-file
"
`;

exports[`getLicenseFileText should omit versions when omitVersions is true 1`] = `
"This file was generated with the generate-license-file npm package!
https://www.npmjs.com/package/generate-license-file
The following npm package may be included in this product:
- dep-four
This package contains the following license and notice below:
# Dep Four
This license file is spelt \`LICENCE\`.
This license should be found.
-----------
The following npm package may be included in this product:
- dep-one
This package contains the following license and notice below:
# Dep One
This license file is spelt \`LICENSE.md\`.
This license should be found.
-----------
The following npm package may be included in this product:
- dep-three
This package contains the following license and notice below:
# Dep Three
This license file is spelt \`LICENSE\`.
This license should be found.
-----------
The following npm packages may be included in this product:
- dep-two
- dep-two-duplicate
These packages each contain the following license and notice below:
# Dep Two
This license file is spelt \`LICENCE.md\`.
This license should be found.
-----------
The following npm package may be included in this product:
- dep-five
This package contains the following license and notice below:
MIT
-----------
This file was generated with the generate-license-file npm package!
https://www.npmjs.com/package/generate-license-file
"
`;
Loading

0 comments on commit 492cb5c

Please sign in to comment.