From 496f13a869faddeabd1cdd553a92c8a38fbe6999 Mon Sep 17 00:00:00 2001 From: kai zhu Date: Mon, 11 Mar 2024 01:27:36 -0500 Subject: [PATCH] - ci - Fix tmpdir in shell-function shBrowserScreenshot(). --- CHANGELOG.md | 1 + README.md | 6 +++--- jslint_ci.sh | 10 ++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74778b299..755335c9f 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.3.1-beta +- ci - Fix tmpdir in shell-function shBrowserScreenshot(). - vim - Allow installing vim-plugin to any directory, instead of hardcoded to ~/.vim/. - ci - Update github-ci for actions/cache, actions/setup-python from nodejs v16 to nodejs v20. - ci - Update shell-function shRollupFetch() to fix blank date-committed. diff --git a/README.md b/README.md index 419fe204d..09e678dd4 100644 --- a/README.md +++ b/README.md @@ -986,7 +986,7 @@ git push upstream beta:master git push origin alpha:branch_xxx git push upstream alpha ``` -- goto https://github.com/jslint-org/jslint/compare/beta...kaizhu256:jslint:branch_xxx +- goto https://github.com/jslint-org/jslint/compare/beta...kaizhu256:jslint:alpha - select branch to merge - click `Create pull request` - `Add a description` template: @@ -994,9 +994,9 @@ git push upstream alpha Fixes #xxx. - -This PR ... +This PR will ... -Additionally, this PR will: +this PR will additionally: - ... diff --git a/jslint_ci.sh b/jslint_ci.sh index c129dd6de..bd7092b6d 100644 --- a/jslint_ci.sh +++ b/jslint_ci.sh @@ -204,6 +204,7 @@ shBrowserScreenshot() {(set -e # window-size $2 node --input-type=module --eval ' import moduleChildProcess from "child_process"; +import moduleFs from "fs"; import moduleOs from "os"; import modulePath from "path"; import moduleUrl from "url"; @@ -225,6 +226,7 @@ import moduleUrl from "url"; let exitCode; let file; let timeStart; + let tmpdir; let url; if (process.platform !== "linux") { return; @@ -244,12 +246,15 @@ import moduleUrl from "url"; file = ".artifact/screenshot_browser_" + encodeURIComponent(file).replace(( /%/g ), "_").toLowerCase() + ".png"; + tmpdir = await moduleFs.promises.mkdtemp( + moduleOs.tmpdir() + "/shBrowserScreenshot-" + ); child = moduleChildProcess.spawn( ( process.platform === "darwin" ? "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" : process.platform === "win32" - ? "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" + ? "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" : "/usr/bin/google-chrome-stable" ), [ @@ -258,7 +263,7 @@ import moduleUrl from "url"; "--incognito", "--screenshot", "--timeout=30000", - "--user-data-dir=" + moduleOs.tmpdir(), + "--user-data-dir=" + tmpdir, "--window-size=800x600", "-screenshot=" + file, ( @@ -277,6 +282,7 @@ import moduleUrl from "url"; exitCode = await new Promise(function (resolve) { child.on("exit", resolve); }); + await moduleFs.promises.rm(tmpdir, {recursive: true}); console.error( "shBrowserScreenshot" + "\n - url - " + url