Skip to content

Commit

Permalink
[CI] Upgrade gulp to v5
Browse files Browse the repository at this point in the history
  • Loading branch information
chalin committed Jun 8, 2024
1 parent fee1f58 commit db5f433
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
30 changes: 25 additions & 5 deletions gulp-src/lint-md.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ const markdownlint = require('markdownlint');
const { taskArgs, trimBlankLinesFromArray } = require('./_util');
const fs = require('fs');

const defaultGlob = '**/*.md';
const defaultGlobs = [
'**/*.md',
];
const markdownFiles = [
'!.github/**',
'!content-modules/**',
'!examples/**',
'!layouts/**',
'!node_modules/**',
'!scripts/registry-scanner/node_modules/**',
'!tools/examples/**',
'!themes/**',
'!tmp/**',
];
Expand Down Expand Up @@ -121,13 +125,25 @@ function applyFixesToFileContent(content, issue) {
return lines.join('\n');
}

function logFiles(debug) {
return through2.obj(function (file, enc, cb) {
if (debug) { console.log('Processing file:', file.path); }
cb(null, file);
});
}

function lintMarkdown() {
const argv = taskArgs().options({
glob: {
alias: 'g',
type: 'string',
description: 'Glob of files to run through markdownlint.',
default: defaultGlob,
type: 'array',
description: 'Globs of files to run through markdownlint. List flag more than once for multiple values.',
default: defaultGlobs,
},
debug: {
type: 'boolean',
description: 'Output debugging information.',
default: false,
},
fix: {
type: 'boolean',
Expand All @@ -142,8 +158,12 @@ function lintMarkdown() {
}
fix = argv.fix;

const globs = [...argv.glob, ...markdownFiles];
if (argv.debug) { console.log('Globs being used:', globs); }

return gulp
.src([argv.glob, ...markdownFiles])
.src(globs, { followSymlinks: false })
.pipe(logFiles(argv.debug))
.pipe(through2.obj(markdownLintFile))
.on('end', () => {
const fileOrFiles = 'file' + (numFilesProcessed == 1 ? '' : 's');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"devDependencies": {
"autoprefixer": "^10.4.19",
"cspell": "^8.8.4",
"gulp": "^4.0.2",
"gulp": "^5.0.0",
"hugo-extended": "0.126.3",
"markdown-link-check": "^3.12.2",
"markdownlint": "^0.34.0",
Expand Down
14 changes: 14 additions & 0 deletions scripts/check-markdown-wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash -e
#
# @chalin can't get Gulp 5 to ignore symlinks, so this wrapper creates
# bogus symlink targets to make the check:markdown Gulp task happy.

symlink_target="content-modules/opentelemetry-go/example"

if [[ ! -e $symlink_target ]]; then
echo "WARNING: required symlink target does not exist, creating it: $symlink_target"
(set -x; mkdir -p $symlink_target)
fi

set -x
exec npx gulp lint-md "$@"

0 comments on commit db5f433

Please sign in to comment.