Only require acknowledgments rebuild in gh lint action
Co-authored-by: ayumi-signal <143036029+ayumi-signal@users.noreply.github.com>
This commit is contained in:
parent
840c98804b
commit
3f8206e66f
2 changed files with 33 additions and 6 deletions
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
|
@ -50,6 +50,12 @@ jobs:
|
||||||
- run: yarn lint
|
- run: yarn lint
|
||||||
- run: yarn lint-deps
|
- run: yarn lint-deps
|
||||||
- run: yarn lint-license-comments
|
- run: yarn lint-license-comments
|
||||||
|
|
||||||
|
- name: Check acknowledgments file is up to date
|
||||||
|
run: yarn build:acknowledgments
|
||||||
|
env:
|
||||||
|
REQUIRE_SIGNAL_LIB_FILES: 1
|
||||||
|
|
||||||
- run: git diff --exit-code
|
- run: git diff --exit-code
|
||||||
|
|
||||||
- name: Update cached .eslintcache and tsconfig.tsbuildinfo
|
- name: Update cached .eslintcache and tsconfig.tsbuildinfo
|
||||||
|
|
|
@ -7,6 +7,11 @@ const { join } = require('path');
|
||||||
const pMap = require('p-map');
|
const pMap = require('p-map');
|
||||||
const prettier = require('prettier');
|
const prettier = require('prettier');
|
||||||
|
|
||||||
|
// During development, you might use local versions of dependencies which are missing
|
||||||
|
// acknowledgment files. In this case we'll skip rebuilding the acknowledgment files.
|
||||||
|
// Enable this flag to throw an error.
|
||||||
|
const REQUIRE_SIGNAL_LIB_FILES = Boolean(process.env.REQUIRE_SIGNAL_LIB_FILES);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
dependencies = {},
|
dependencies = {},
|
||||||
optionalDependencies = {},
|
optionalDependencies = {},
|
||||||
|
@ -76,12 +81,28 @@ async function getMarkdownForSignalLib(dependencyName) {
|
||||||
'dist',
|
'dist',
|
||||||
'acknowledgments.md'
|
'acknowledgments.md'
|
||||||
);
|
);
|
||||||
const licenseBody = (await fs.promises.readFile(licenseFilePath, 'utf8'))
|
|
||||||
.replace(/^# Acknowledgments/, '')
|
let licenseBody;
|
||||||
.trim();
|
try {
|
||||||
return [`# Acknowledgements for ${dependencyName}`, '', licenseBody].join(
|
licenseBody = await fs.promises.readFile(licenseFilePath, 'utf8');
|
||||||
'\n'
|
} catch (err) {
|
||||||
|
if (err) {
|
||||||
|
if (err.code === 'ENOENT' && !REQUIRE_SIGNAL_LIB_FILES) {
|
||||||
|
console.warn(
|
||||||
|
`Missing acknowledgments file for ${dependencyName}. Skipping generation of acknowledgments.`
|
||||||
);
|
);
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
`# Acknowledgements for ${dependencyName}`,
|
||||||
|
'',
|
||||||
|
licenseBody.replace(/^# Acknowledgments/, '').trim(),
|
||||||
|
].join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue