4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@@ -97,11 +97,11 @@ jobs:
|
||||
run: |
|
||||
# If either of these fail, it means our fixture content's internal
|
||||
# links can and should be updated.
|
||||
./script/update-internal-links.js --dry-run --check --strict --verbose \
|
||||
./script/update-internal-links.js --dry-run --check --strict \
|
||||
tests/fixtures/content \
|
||||
--exclude tests/fixtures/content/get-started/foo/typo-autotitling.md \
|
||||
--exclude tests/fixtures/content/get-started/foo/anchor-autotitling.md
|
||||
./script/update-internal-links.js --dry-run --check --strict --verbose \
|
||||
./script/update-internal-links.js --dry-run --check --strict \
|
||||
tests/fixtures/data
|
||||
|
||||
- name: Clone all translations
|
||||
|
||||
@@ -22,7 +22,7 @@ import walkFiles from './helpers/walk-files.js'
|
||||
|
||||
program
|
||||
.description('Update internal links in content files')
|
||||
.option('-v, --verbose', 'Verbose outputs')
|
||||
.option('--silent', 'The opposite of verbose')
|
||||
.option('--debug', "Don't hide any errors")
|
||||
.option('--dry-run', "Don't actually write changes to disk")
|
||||
.option('--dont-set-autotitle', "Do NOT transform the link text to 'AUTOTITLE' (if applicable)")
|
||||
@@ -77,11 +77,17 @@ async function main(files, opts) {
|
||||
throw new Error(`No files found in ${files}`)
|
||||
}
|
||||
|
||||
const verbose = !opts.silent
|
||||
|
||||
if (verbose) {
|
||||
console.log(chalk.bold(`Updating internal links in ${actualFiles.length} found files...`))
|
||||
}
|
||||
|
||||
// The updateInternalLinks doesn't use "negatives" for certain options
|
||||
const options = {
|
||||
setAutotitle: !opts.dontSetAutotitle,
|
||||
fixHref: !opts.dontFixHref,
|
||||
verbose: !!opts.verbose,
|
||||
verbose,
|
||||
strict: !!opts.strict,
|
||||
}
|
||||
|
||||
@@ -108,11 +114,11 @@ async function main(files, opts) {
|
||||
const differentContent = content !== newContent
|
||||
const differentData = !equalObject(data, newData)
|
||||
if (differentContent || differentData) {
|
||||
if (opts.verbose || opts.check) {
|
||||
if (verbose || opts.check) {
|
||||
if (opts.check) {
|
||||
exitCheck++
|
||||
}
|
||||
if (opts.verbose) {
|
||||
if (verbose) {
|
||||
console.log(
|
||||
opts.dryRun ? 'Would change...' : 'Will change...',
|
||||
chalk.bold(file),
|
||||
@@ -188,7 +194,9 @@ async function main(files, opts) {
|
||||
}
|
||||
|
||||
if (exitCheck) {
|
||||
console.log(chalk.yellow(`More than one file would become different. Unsuccessful check.`))
|
||||
if (verbose) {
|
||||
console.log(chalk.yellow(`More than one file would become different. Unsuccessful check.`))
|
||||
}
|
||||
process.exit(exitCheck)
|
||||
} else if (opts.check) {
|
||||
console.log(chalk.green('No changes needed or necessary. 🌈'))
|
||||
|
||||
Reference in New Issue
Block a user