From 33ff0e7da388bf6efdf284191b1af9d96f167b1a Mon Sep 17 00:00:00 2001 From: kai zhu Date: Sun, 23 Jun 2024 17:38:51 -0500 Subject: [PATCH 1/3] - coverage - Fix coverage-function v8CoverageReportCreate() throwing error EINVAL in latest nodejs-security-patch, when running win32-coverage with npm.cmd. --- .ci.sh | 2 +- .github/workflows/ci.yml | 10 ++--- .github/workflows/on_pull_request.yml | 14 +++---- .github/workflows/publish.yml | 1 - CHANGELOG.md | 3 ++ README.md | 56 +++++++++++++-------------- jslint.mjs | 37 ++++++++++++------ jslint_ci.sh | 37 +++++++++++------- package.json | 2 +- 9 files changed, 91 insertions(+), 71 deletions(-) diff --git a/.ci.sh b/.ci.sh index 366939825..11fdec961 100644 --- a/.ci.sh +++ b/.ci.sh @@ -441,7 +441,7 @@ import moduleFs from "fs"; "type": "git", "url": "https://github.com/jslint-org/jslint.git" }, - "version": "2024.3.26" + "version": "2024.6.1" }, undefined, 4) } ].map(async function ({ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 314bcb6df..00d16ba9d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,15 +22,14 @@ jobs: - x64 # - x86 node_version: - - 18 - 20 - # - 22 - python_version: - - "3.10" + - 22 os: - macos-latest - ubuntu-latest - windows-latest + python_version: + - "3.10" # base - .github/workflows/ci.yml - beg env: CI_MATRIX_NAME: > @@ -55,7 +54,7 @@ jobs: steps: # disable autocrlf in windows - run: | - sh -c uname + sh -c "uname -a" echo "$(date -u +"%Y-%m-%d %TZ") - ${{ env.CI_WORKFLOW_NAME }}" # " git config --global core.autocrlf false # https://github.com/actions/checkout @@ -70,7 +69,6 @@ jobs: # https://github.com/actions/setup-node - uses: actions/setup-node@v4 with: - architecture: ${{ matrix.architecture }} node-version: ${{ matrix.node_version }} # https://github.com/actions/setup-python - uses: actions/setup-python@v5 diff --git a/.github/workflows/on_pull_request.yml b/.github/workflows/on_pull_request.yml index d43fdd64c..d9feec7c7 100644 --- a/.github/workflows/on_pull_request.yml +++ b/.github/workflows/on_pull_request.yml @@ -14,9 +14,8 @@ jobs: - x64 # - x86 node_version: - - 18 - 20 - # - 22 + - 22 os: - macos-latest - ubuntu-latest @@ -43,20 +42,21 @@ jobs: ${{ matrix.os }} runs-on: ${{ matrix.os }} steps: - - run: echo "$(date -u +"%Y-%m-%d %TZ") - ${{ env.CI_WORKFLOW_NAME }}" # " # disable autocrlf in windows - - run: git config --global core.autocrlf false + - run: | + sh -c "uname -a" + echo "$(date -u +"%Y-%m-%d %TZ") - ${{ env.CI_WORKFLOW_NAME }}" # " + git config --global core.autocrlf false # https://github.com/actions/checkout - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # fetch jslint_ci.sh from trusted source - run: | git fetch origin alpha --depth=1 sh -c 'for FILE in .ci.sh .ci2.sh jslint_ci.sh myci2.sh; do if [ -f "$FILE" ]; then git checkout origin/alpha "$FILE"; fi; done' # https://github.com/actions/setup-node - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: - architecture: ${{ matrix.architecture }} node-version: ${{ matrix.node_version }} # run nodejs coverages and tests - run: sh jslint_ci.sh shCiBase diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 31995a89a..80cf34292 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -17,7 +17,6 @@ jobs: - x64 # - x86 node_version: - # - 18 - 20 # - 22 os: diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e2e77e70..bdbfbfc0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ - jslint - add new warning requiring paren around plus-separated concatenations. - jslint - try to improve parser to be able to parse jquery.js without stopping. +# v2024.6.1-beta +- coverage - Fix coverage-function v8CoverageReportCreate() throwing error EINVAL in latest nodejs-security-patch, when running win32-coverage with npm.cmd. + # v2024.3.26 - ci - Add shell-functions shGitPullrequestCleanup(), shGitPullrequest() to automatically cleanup or create-and-push github-pull-commit to origin/alpha. - jslint - Allow destructuring-assignment after function-definition. diff --git a/README.md b/README.md index 7125ffe5d..83f07a771 100644 --- a/README.md +++ b/README.md @@ -917,13 +917,13 @@ eval("1"); //jslint-ignore-line

### pull-request merge - find highest issue-number at https://github.com/jslint-org/jslint/issues/, https://github.com/jslint-org/jslint/pulls/, and add +1 to it for PR-xxx -- $ `shGitPullrequest beta beta` +- `shGitPullrequest beta beta` - verify ci-success for origin-branch-alpha - - https://github.com/kaizhu256/jslint/actions/workflows/ci.yml -- $ `git push upstream alpha -f` + - https://github.com/kaizhu256/jslint/actions +- `git push upstream alpha -f` - verify ci-success for upstream-branch-alpha - - https://github.com/jslint-org/jslint/actions/workflows/ci.yml -- goto https://github.com/jslint-org/jslint/compare/beta...kaizhu256:jslint:branch-p2024.3.21 + - https://github.com/jslint-org/jslint/actions +- goto https://github.com/jslint-org/jslint/compare/beta...kaizhu256:jslint:branch-p2024.6.23 - click `Create pull request` - input `Add your description here...` with: ``` @@ -945,24 +945,24 @@ this PR will additionally: - wait awhile before continuing ... - click `Rebase and merge` - verify ci-success for upstream-branch-beta - - https://github.com/jslint-org/jslint/actions/workflows/ci.yml -- $ `shGitPullrequestCleanup` + - https://github.com/jslint-org/jslint/actions +- `shGitPullrequestCleanup` - verify ci-success for origin-branch-alpha - - https://github.com/kaizhu256/jslint/actions/workflows/ci.yml -- $ `git push upstream alpha -f` + - https://github.com/kaizhu256/jslint/actions +- `git push upstream alpha -f` - verify ci-success for upstream-branch-alpha - - https://github.com/jslint-org/jslint/actions/workflows/ci.yml + - https://github.com/jslint-org/jslint/actions - click `Delete branch`

### branch-master commit -- $ `shGitPullrequest master beta` +- `shGitPullrequest master beta` - verify ci-success for origin-branch-alpha - - https://github.com/kaizhu256/jslint/actions/workflows/ci.yml -- $ `git push upstream alpha -f` + - https://github.com/kaizhu256/jslint/actions +- `git push upstream alpha -f` - verify ci-success for upstream-branch-alpha - - https://github.com/jslint-org/jslint/actions/workflows/ci.yml + - https://github.com/jslint-org/jslint/actions - goto https://github.com/jslint-org/jslint/compare/beta...kaizhu256:jslint:branch-v2024.3.26 - click `Create pull request` - input `Add a title` with: `# v20yy.mm.dd` @@ -978,27 +978,27 @@ this PR will additionally: - wait awhile before continuing ... - click `Rebase and merge` - verify ci-success for upstream-branch-beta - - https://github.com/jslint-org/jslint/actions/workflows/ci.yml -- $ `shGitPullrequestCleanup` + - https://github.com/jslint-org/jslint/actions +- `shGitPullrequestCleanup` - verify ci-success for origin-branch-alpha - - https://github.com/kaizhu256/jslint/actions/workflows/ci.yml -- $ `git push upstream alpha -f` + - https://github.com/kaizhu256/jslint/actions +- `git push upstream alpha -f` - verify ci-success for upstream-branch-alpha - - https://github.com/jslint-org/jslint/actions/workflows/ci.yml + - https://github.com/jslint-org/jslint/actions - click `Delete branch` -- $ `git push origin beta:master` +- `git push origin beta:master` - verify ci-success for origin-branch-master - - https://github.com/kaizhu256/jslint/actions/workflows/ci.yml -- $ `git push upstream beta:master` + - https://github.com/kaizhu256/jslint/actions +- `git push upstream beta:master` - verify ci-success for upstream-branch-master - - https://github.com/jslint-org/jslint/actions/workflows/ci.yml + - https://github.com/jslint-org/jslint/actions

### branch-master publish -- $ `git push upstream beta:master` +- `git push upstream beta:master` - verify ci-success for upstream-branch-master - - https://github.com/jslint-org/jslint/actions/workflows/ci.yml + - https://github.com/jslint-org/jslint/actions - goto https://github.com/jslint-org/jslint/releases/new - input `Choose a tag` with: `v20yy.mm.dd` - click `Create new tag: v20yy.mm.dd on publish` @@ -1016,7 +1016,7 @@ this PR will additionally: - click `Preview` and review - click `Publish release` - verify ci-success for upstream-branch-publish - - https://github.com/jslint-org/jslint/actions/workflows/ci.yml + - https://github.com/jslint-org/jslint/actions - verify email-notification `Successfully published @jslint-org/jslint@20yy.mm.dd` @@ -1024,10 +1024,10 @@ this PR will additionally: ### vscode-jslint publish - goto https://github.com/jslint-org/jslint/tree/gh-pages/branch-beta/.artifact/jslint_wrapper_vscode - click `vscode-jslint-20yy.mm.dd.vsix` -- click `Download` +- click `Raw` to download - goto https://marketplace.visualstudio.com/manage/publishers/jslint - right-click `Update` -- drag-and-drop downloaded `vscode-jslint-20yy.mm.dd.vsix` +- upload downloaded file `vscode-jslint-20yy.mm.dd.vsix` - click 'Upload' - verify email-notification `[Succeeded] Extension publish on Visual Studio Marketplace - vscode-jslint` diff --git a/jslint.mjs b/jslint.mjs index b8dd1d950..1cc3d1796 100644 --- a/jslint.mjs +++ b/jslint.mjs @@ -125,8 +125,8 @@ process_env, process_exit, promises, property, property_dict, push, quote, ranges, readFile, readdir, readonly, recursive, reduce, repeat, replace, resolve, result, reverse, role, round, scriptId, search, set, shebang, - shift, signature, single, slice, some, sort, source, spawn, splice, split, - stack, stack_trace, start, startOffset, startsWith, statement, + shell, shift, signature, single, slice, some, sort, source, spawn, splice, + split, stack, stack_trace, start, startOffset, startsWith, statement, statement_prv, stdio, stop, stop_at, stringify, subscript, switch, syntax_dict, tenure, test, test_cause, test_internal_error, this, thru, toLocaleString, toString, token, token_global, token_list, token_nxt, @@ -163,7 +163,7 @@ let jslint_charset_ascii = ( + "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" + "`abcdefghijklmnopqrstuvwxyz{|}~\u007f" ); -let jslint_edition = "v2024.3.26"; +let jslint_edition = "v2024.6.1-beta"; let jslint_export; // The jslint object to be exported. let jslint_fudge = 1; // Fudge starting line and starting // ... column to 1. @@ -11285,24 +11285,37 @@ function sentinel() {} } })); exitCode = await new Promise(function (resolve) { - moduleChildProcess.spawn( - ( - processArgv[0] === "npm" + let processArgv0 = processArgv[0]; // If win32 environment, then replace program npm with npm.cmd. // Coverage-hack - Ugly-hack to get test-coverage under both win32 and linux. - ? process.platform.replace("win32", "npm.cmd").replace( - process.platform, - "npm" - ) - : processArgv[0] - ), + if (processArgv0 === "npm") { + processArgv0 = process.platform.replace( + "win32", + "npm.cmd" + ).replace( + process.platform, + "npm" + ); + } + moduleChildProcess.spawn( + processArgv0, processArgv.slice(1), { env: Object.assign({}, process.env, { NODE_V8_COVERAGE: coverageDir }), + +// PR-465 +// https://nodejs.org/en/blog/vulnerability/april-2024-security-releases-2 +// Node.js will now error with EINVAL if a .bat or .cmd file is passed to +// child_process.spawn and child_process.spawnSync without the shell option set. + + shell: ( + processArgv0.endsWith(".bat") + || processArgv0.endsWith(".cmd") + ), stdio: ["ignore", 1, 2] } ).on("exit", resolve); diff --git a/jslint_ci.sh b/jslint_ci.sh index 6bef270fb..2f5490808 100644 --- a/jslint_ci.sh +++ b/jslint_ci.sh @@ -922,7 +922,7 @@ shGitInitBase() {(set -e shGitLsTree() {(set -e # this function will "git ls-tree" all files committed in HEAD -# example use: +# example usage: # shGitLsTree | sort -rk3 # sort by date # shGitLsTree | sort -rk4 # sort by size node --input-type=module --eval ' @@ -1062,7 +1062,7 @@ import moduleFs from "fs"; default: version = `p${version}`; commitMessage = ( - /\n\n# v\d\d\d\d\.\d\d?\.\d\d?(?:-.*?)?\n(- [\S\s]+?)\n- / + /\n\n# v\d\d\d\d\.\d\d?\.\d\d?(?:-.*?)?\n(- [\S\s]+?)(?:\n- |\n\n)/ ).exec(data)[1]; } branchPull = `branch-${version}`; @@ -1171,7 +1171,7 @@ shGithubCheckoutRemote() {(set -e shGithubFileDownload() {(set -e # this function will download file $1 from github repo/branch # https://docs.github.com/en/rest/reference/repos#create-or-update-file-contents -# example use: +# example usage: # shGithubFileDownload octocat/hello-world/master/hello.txt shGithubFileDownloadUpload download "$1" "$2" )} @@ -1179,7 +1179,7 @@ shGithubFileDownload() {(set -e shGithubFileDownloadUpload() {(set -e # this function will upload file $2 to github repo/branch $1 # https://docs.github.com/en/rest/reference/repos#create-or-update-file-contents -# example use: +# example usage: # shGithubFileUpload octocat/hello-world/master/hello.txt hello.txt shGithubTokenExport node --input-type=module --eval ' @@ -1272,7 +1272,7 @@ import modulePath from "path"; shGithubFileUpload() {(set -e # this function will upload file $2 to github repo/branch $1 # https://docs.github.com/en/rest/reference/repos#create-or-update-file-contents -# example use: +# example usage: # shGithubFileUpload octocat/hello-world/master/hello.txt hello.txt shGithubFileDownloadUpload upload "$1" "$2" )} @@ -1287,7 +1287,7 @@ shGithubTokenExport() { shGithubWorkflowDispatch() {(set -e # this function will trigger github-workflow on given $REPO and $BRANCH -# example use: +# example usage: # shGithubWorkflowDispatch octocat/hello-world master shGithubTokenExport REPO="$1" @@ -2068,7 +2068,7 @@ function replaceListReplace(replaceList, data) { if (dataUriType) { return; } - if (dateCommitted) { + if (dateCommitted && dateCommitted.toString()) { result += ( "\n\n\n/*\n" + "repo " + prefix.replace("/blob/", "/tree/") + "\n" @@ -3329,20 +3329,27 @@ function sentinel() {} } })); exitCode = await new Promise(function (resolve) { + let processArgv0 = processArgv[0]; + if (processArgv0 === "npm") { + processArgv0 = process.platform.replace( + "win32", + "npm.cmd" + ).replace( + process.platform, + "npm" + ); + } moduleChildProcess.spawn( - ( - processArgv[0] === "npm" - ? process.platform.replace("win32", "npm.cmd").replace( - process.platform, - "npm" - ) - : processArgv[0] - ), + processArgv0, processArgv.slice(1), { env: Object.assign({}, process.env, { NODE_V8_COVERAGE: coverageDir }), + shell: ( + processArgv0.endsWith(".bat") + || processArgv0.endsWith(".cmd") + ), stdio: ["ignore", 1, 2] } ).on("exit", resolve); diff --git a/package.json b/package.json index 27dc431ea..a1aed18f5 100644 --- a/package.json +++ b/package.json @@ -35,5 +35,5 @@ "shCiArtifactUpload": 1, "shCiPublishNpm": 1, "type": "module", - "version": "2024.3.26" + "version": "2024.6.1-beta" } From 253d42d08f45bd6499978344bcd62b836cd7b996 Mon Sep 17 00:00:00 2001 From: Kai Zhu Date: Mon, 24 Jun 2024 14:09:52 -0500 Subject: [PATCH 2/3] - doc - Cleanup comments in file jslint_ci.sh. --- jslint_ci.sh | 97 ++++++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 49 deletions(-) diff --git a/jslint_ci.sh b/jslint_ci.sh index 2f5490808..1a44fa48d 100644 --- a/jslint_ci.sh +++ b/jslint_ci.sh @@ -57,7 +57,7 @@ # `abcdefghijklmnopqrstuvwxyz{|}~\u007f shBashrcDebianInit() { -# this function will init debian:stable /etc/skel/.bashrc +# This function will init debian:stable /etc/skel/.bashrc. # https://sources.debian.org/src/bash/4.4-5/debian/skel.bashrc/ # ~/.bashrc: executed by bash(1) for non-login shells. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) @@ -175,7 +175,7 @@ shBashrcDebianInit() { } shBashrcWindowsInit() { -# this function will init windows-environment +# This function will init windows-environment. case "$(uname)" in CYGWIN*) ;; @@ -200,8 +200,7 @@ shBashrcWindowsInit() { } shBrowserScreenshot() {(set -e -# this function will run headless-chrome to screenshot url $1 with -# window-size $2 +# This function will run headless-chrome to screenshot url $1. node --input-type=module --eval ' import moduleChildProcess from "child_process"; import moduleFs from "fs"; @@ -282,9 +281,9 @@ import moduleUrl from "url"; )} shCiArtifactUpload() {(set -e -# this function will upload build-artifacts to branch-gh-pages +# This function will upload build-artifacts to branch-gh-pages. # shCiArtifactUploadCustom() {(set -e -# # this function will run custom-code to upload build-artifacts +# # This function will run custom-code to upload build-artifacts. # return # )} if ! (shCiMatrixIsmainName \ @@ -412,13 +411,13 @@ import moduleChildProcess from "child_process"; )} shCiBase() {(set -e -# this function will run base-ci +# This function will run base-ci. # shCiBaseCustom() {(set -e -# # this function will run custom-code for base-ci +# # This function will run custom-code for base-ci. # return # )} # shCiLintCustom() {(set -e -# # this function will run custom-code to lint files +# # This function will run custom-code to lint files. # )} export GITHUB_BRANCH0="$(git rev-parse --abbrev-ref HEAD)" # Auto-correct common errors in package.json. @@ -577,21 +576,21 @@ import moduleFs from "fs"; )} shCiMatrixIsmainName() {(set -e -# this function will return 0 if current ci-job is main job +# This function will return 0 if current ci-job is main job. CI_MATRIX_NAME="$(printf "$CI_MATRIX_NAME" | xargs)" [ "$CI_MATRIX_NAME" ] && [ "$CI_MATRIX_NAME" = "$CI_MATRIX_NAME_MAIN" ] )} shCiMatrixIsmainNodeversion() {(set -e -# this function will return 0 if current ci-job is main job +# This function will return 0 if current ci-job is main job. [ "$CI_MATRIX_NODE_VERSION" ] \ && [ "$CI_MATRIX_NODE_VERSION" = "$CI_MATRIX_NODE_VERSION_MAIN" ] )} shCiPre() {(set -e -# this function will run pre-ci +# This function will run pre-ci. # shCiPreCustom() {(set -e -# # this function will run custom-code for pre-ci +# # This function will run custom-code for pre-ci. # return # )} if [ -f ./myci2.sh ] @@ -610,9 +609,9 @@ shCiPre() {(set -e )} shCiPublishNpm() {(set -e -# this function will publish npm-package +# This function will publish npm-package. # shCiPublishNpmCustom() {(set -e -# # this function will run custom-code to npm-publish package +# # This function will run custom-code to publish npm-package. # # npm publish --access public # )} if ! ([ -f package.json ] \ @@ -636,9 +635,9 @@ shCiPublishNpm() {(set -e )} shCiPublishPypi() {(set -e -# this function will publish pypi-package +# This function will publish pypi-package. # shCiPublishPypiCustom() {(set -e -# # this function will run custom-code to npm-publish package +# # This function will run custom-code to publish pypi-package. # # npm publish --access public # )} if ! ([ -f pyproject.toml ] \ @@ -653,7 +652,7 @@ shCiPublishPypi() {(set -e )} shCurlExe() {(set -e -# this function will print to stdout "curl.exe", if it exists, else "curl" +# This function will print to stdout "curl.exe", if it exists, else "curl". if [ -f c:/windows/system32/curl.exe ] then printf c:/windows/system32/curl.exe @@ -663,7 +662,7 @@ shCurlExe() {(set -e )} shDirHttplinkValidate() {(set -e -# this function will validate http-links embedded in .html and .md files +# This function will validate http-links embedded in .html and .md files. # init $GITHUB_BRANCH0 export GITHUB_BRANCH0="${GITHUB_BRANCH0:-alpha}" # init $UPSTREAM_XXX @@ -801,12 +800,12 @@ import moduleHttps from "https"; )} shDuList() {(set -e -# this function will du $1 and sort its subdir by size +# This function will du $1 and sort its subdir by size. du -md1 "$1" | sort -nr )} shGitCmdWithGithubToken() {(set -e -# this function will run git $CMD with $MY_GITHUB_TOKEN +# This function will run git $CMD with $MY_GITHUB_TOKEN. printf "shGitCmdWithGithubToken $*\n" if [ -f .git/config ] then @@ -850,9 +849,9 @@ shGitCmdWithGithubToken() {(set -e )} shGitCommitPushOrSquash() {(set -e -# this function will, if $COMMIT_COUNT > $COMMIT_LIMIT, +# This function will, if $COMMIT_COUNT > $COMMIT_LIMIT, # then backup, squash, force-push, -# else normal-push +# else normal-push. BRANCH="$(git branch --show-current)" COMMIT_MESSAGE="${1:-$(git diff HEAD --stat)}" COMMIT_LIMIT="$2" @@ -890,7 +889,7 @@ COMMIT_LIMIT=$COMMIT_LIMIT MODE_SQUASH=$MODE_SQUASH\n" )} shGitGc() {(set -e -# this function will gc unreachable .git objects +# This function will gc unreachable .git objects. # http://stackoverflow.com/questions/3797907/how-to-remove-unused-objects-from-a-git-repository git remote prune origin git \ @@ -903,7 +902,7 @@ shGitGc() {(set -e )} shGitInitBase() {(set -e -# this function will git init && create basic git-template from jslint-org/base +# This function will git init && create basic git-template from jslint-org/base. git init git config core.autocrlf input git remote remove base 2>/dev/null || true @@ -921,7 +920,7 @@ shGitInitBase() {(set -e )} shGitLsTree() {(set -e -# this function will "git ls-tree" all files committed in HEAD +# This function will "git ls-tree" all files committed in HEAD. # example usage: # shGitLsTree | sort -rk3 # sort by date # shGitLsTree | sort -rk4 # sort by size @@ -998,7 +997,7 @@ import moduleChildProcess from "child_process"; )} shGitPullrequestCleanup() {(set -e -# this function will cleanup pull-request after merge. +# This function will cleanup pull-request after merge. git fetch upstream beta # verify no diff between alpha..upstream/beta git diff alpha..upstream/beta @@ -1011,7 +1010,7 @@ shGitPullrequestCleanup() {(set -e )} shGitPullrequest() {(set -e -# this function will create-and-push a github-pull-commit to origin/alpha +# This function will create-and-push a github-pull-commit to origin/alpha. node --input-type=module --eval ' // init debugInline (function () { @@ -1113,7 +1112,7 @@ import moduleFs from "fs"; )} shGitSquashPop() {(set -e -# this function will squash HEAD to given $COMMIT +# This function will squash HEAD to given $COMMIT. # http://stackoverflow.com/questions/5189560 # /how-can-i-squash-my-last-x-commits-together-using-git COMMIT="$1" @@ -1126,7 +1125,7 @@ shGitSquashPop() {(set -e )} shGithubCheckoutRemote() {(set -e -# this function will run like actions/checkout, except checkout remote-branch +# This function will run like actions/checkout, except checkout remote-branch. # GITHUB_REF_NAME="owner/repo/branch" GITHUB_REF_NAME="$1" if (printf "$GITHUB_REF_NAME" | grep -q ".*/.*/.*") @@ -1169,7 +1168,7 @@ shGithubCheckoutRemote() {(set -e )} shGithubFileDownload() {(set -e -# this function will download file $1 from github repo/branch +# This function will download file $1 from github repo/branch. # https://docs.github.com/en/rest/reference/repos#create-or-update-file-contents # example usage: # shGithubFileDownload octocat/hello-world/master/hello.txt @@ -1177,7 +1176,7 @@ shGithubFileDownload() {(set -e )} shGithubFileDownloadUpload() {(set -e -# this function will upload file $2 to github repo/branch $1 +# This function will upload file $2 to github repo/branch $1. # https://docs.github.com/en/rest/reference/repos#create-or-update-file-contents # example usage: # shGithubFileUpload octocat/hello-world/master/hello.txt hello.txt @@ -1270,7 +1269,7 @@ import modulePath from "path"; )} shGithubFileUpload() {(set -e -# this function will upload file $2 to github repo/branch $1 +# This function will upload file $2 to github repo/branch $1. # https://docs.github.com/en/rest/reference/repos#create-or-update-file-contents # example usage: # shGithubFileUpload octocat/hello-world/master/hello.txt hello.txt @@ -1278,7 +1277,7 @@ shGithubFileUpload() {(set -e )} shGithubTokenExport() { -# this function will export $MY_GITHUB_TOKEN from file +# This function will export $MY_GITHUB_TOKEN from file. if [ ! "$MY_GITHUB_TOKEN" ] then export MY_GITHUB_TOKEN="$(cat ~/.mysecret2/.my_github_token)" @@ -1286,7 +1285,7 @@ shGithubTokenExport() { } shGithubWorkflowDispatch() {(set -e -# this function will trigger github-workflow on given $REPO and $BRANCH +# This function will trigger github-workflow on given $REPO and $BRANCH. # example usage: # shGithubWorkflowDispatch octocat/hello-world master shGithubTokenExport @@ -1308,7 +1307,7 @@ shGithubWorkflowDispatch() {(set -e )} shGrep() {(set -e -# this function will recursively grep . for $REGEXP +# This function will recursively grep . for $REGEXP. REGEXP="$1" shift FILE_FILTER="\ @@ -1338,7 +1337,7 @@ vendor)s{0,1}(\\b|_)\ )} shGrepReplace() {(set -e -# this function will inline grep-and-replace /tmp/shGrep.txt +# This function will inline grep-and-replace /tmp/shGrep.txt. node --input-type=module --eval ' import moduleFs from "fs"; import moduleOs from "os"; @@ -1370,7 +1369,7 @@ import modulePath from "path"; )} shHttpFileServer() {(set -e -# this function will run simple node http-file-server on port $PORT +# This function will run simple node http-file-server on port $PORT. if [ ! "$npm_config_mode_auto_restart" ] then EXIT_CODE=0 @@ -1636,7 +1635,7 @@ import moduleUrl from "url"; )} shImageLogoCreate() {(set -e -# this function will create .png logo +# This function will create .png logo. if [ ! -f asset_image_logo_512.html ] then return @@ -1658,7 +1657,7 @@ shImageLogoCreate() {(set -e )} shImageToDataUri() {(set -e -# this function will convert image $1 to data-uri string +# This function will convert image $1 to data-uri string. node --input-type=module --eval ' import moduleFs from "fs"; import moduleHttps from "https"; @@ -1696,7 +1695,7 @@ import moduleHttps from "https"; )} shJsonNormalize() {(set -e -# this function will +# This function will: # 1. read json-data from file $1 # 2. normalize json-data # 3. write normalized json-data back to file $1 @@ -1757,7 +1756,7 @@ function objectDeepCopyWithKeysSorted(obj) { )} shLintPython() {(set -e -# this function will lint python file +# This function will lint python file. FILE_LIST="$@" ( printf "\n\nlint ruff\n" @@ -1823,7 +1822,7 @@ shLintPython() {(set -e )} shNpmPublishV0() {(set -e -# this function will npm-publish name $1 with bare package.json +# This function will npm-publish name $1 with bare package.json. DIR=/tmp/shNpmPublishV0 rm -rf "$DIR" && mkdir -p "$DIR" && cd "$DIR" printf "{\"name\":\"$1\",\"version\":\"0.0.1\"}\n" > package.json @@ -1832,7 +1831,7 @@ shNpmPublishV0() {(set -e )} shPidListWait() { -# this will wait for all process-pid in $PID_LIST to exit +# This function will wait for all process-pid in $PID_LIST to exit. EXIT_CODE=0 PID_LIST="$2" TASK="$1" @@ -1847,7 +1846,7 @@ shPidListWait() { } shRmDsStore() {(set -e -# this function will recursively rm .DS_Store from current-dir +# This function will recursively rm .DS_Store from current-dir. # http://stackoverflow.com/questions/2016844/bash-recursively-remove-files for NAME in "._*" ".DS_Store" "desktop.ini" "npm-debug.log" "*~" do @@ -1856,7 +1855,7 @@ shRmDsStore() {(set -e )} shRollupFetch() {(set -e -# this function will fetch raw-lib from $1 +# This function will fetch raw-lib from $1. node --input-type=module --eval ' import moduleChildProcess from "child_process"; import moduleFs from "fs"; @@ -2219,8 +2218,8 @@ function replaceListReplace(replaceList, data) { )} shRunWithCoverage() {(set -e -# this function will run nodejs command $@ with v8-coverage -# and create coverage-report .artifact/coverage/index.html +# This function will run nodejs command $@ with v8-coverage +# and create coverage-report .artifact/coverage/index.html. node --input-type=module --eval ' /*jslint indent2*/ let moduleChildProcess; @@ -3524,7 +3523,7 @@ v8CoverageReportCreate({ )} shRunWithScreenshotTxt() {(set -e -# this function will run cmd $@ and screenshot text-output +# This function will run cmd $@ and screenshot text-output. # https://www.cnx-software.com/2011/09/22/how-to-convert-a-command-line-result-into-an-image-in-linux/ EXIT_CODE=0 SCREENSHOT_SVG="$1" From 26987edb483f143da1e442beccff61ee3c8323cd Mon Sep 17 00:00:00 2001 From: Kai Zhu Date: Mon, 24 Jun 2024 14:17:24 -0500 Subject: [PATCH 3/3] - jslint - Remove unnecessary shell-function shCurlExe(). --- CHANGELOG.md | 1 + jslint_ci.sh | 12 +----------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bdbfbfc0f..13303d33b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - jslint - try to improve parser to be able to parse jquery.js without stopping. # v2024.6.1-beta +- jslint - Remove unnecessary shell-function shCurlExe(). - coverage - Fix coverage-function v8CoverageReportCreate() throwing error EINVAL in latest nodejs-security-patch, when running win32-coverage with npm.cmd. # v2024.3.26 diff --git a/jslint_ci.sh b/jslint_ci.sh index 1a44fa48d..d2a2e439f 100644 --- a/jslint_ci.sh +++ b/jslint_ci.sh @@ -651,16 +651,6 @@ shCiPublishPypi() {(set -e fi )} -shCurlExe() {(set -e -# This function will print to stdout "curl.exe", if it exists, else "curl". - if [ -f c:/windows/system32/curl.exe ] - then - printf c:/windows/system32/curl.exe - return - fi - printf curl -)} - shDirHttplinkValidate() {(set -e # This function will validate http-links embedded in .html and .md files. # init $GITHUB_BRANCH0 @@ -1294,7 +1284,7 @@ shGithubWorkflowDispatch() {(set -e BRANCH="$1" shift EXIT_CODE=0 - "$(shCurlExe)" \ + curl \ "https://api.github.com/repos/$REPO/actions/workflows/ci.yml/dispatches" \ -H "accept: application/vnd.github.v3+json" \ -H "authorization: Bearer $MY_GITHUB_TOKEN" \