From 4732c1986c0c1b0df5bb97d3d4ddcaaa401cbe24 Mon Sep 17 00:00:00 2001 From: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> Date: Sat, 2 Sep 2023 09:34:39 +0900 Subject: [PATCH] refactor: use `process` module instead of global variable (#784) * refactor: use `process` module instead of global variable * ci: use npm@9 instead of npm@10 --- .github/workflows/test.yml | 2 +- dist/index.cjs | 9 ++++++--- lib/index.js | 1 + lib/listPackages.js | 1 + lib/updateNpm.js | 1 + 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b5946f04..093271b2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: with: node-version-file: .node-version cache: npm - - run: npm --global install npm@latest + - run: npm install --global npm@9 - run: npm ci - run: git diff --exit-code # check dist/ - run: npm test --ignore-scripts diff --git a/dist/index.cjs b/dist/index.cjs index 54efa47c..575f1731 100644 --- a/dist/index.cjs +++ b/dist/index.cjs @@ -10495,6 +10495,7 @@ var require_github = __commonJS({ }); // lib/index.js +var import_node_process3 = __toESM(require("node:process"), 1); var core2 = __toESM(require_core(), 1); var import_exec7 = __toESM(require_exec(), 1); @@ -10892,9 +10893,10 @@ async function getDefaultBranch({ token, repository }) { } // lib/listPackages.js +var import_node_process = __toESM(require("node:process"), 1); var import_exec5 = __toESM(require_exec(), 1); async function listPackages(options = {}) { - const cwd = options.cwd || process.cwd(); + const cwd = options.cwd || import_node_process.default.cwd(); const { exitCode, stdout, stderr } = await (0, import_exec5.getExecOutput)( "npm", npmArgs("ls", "--parseable", "--long", "--all", "--package-lock-only"), @@ -10921,6 +10923,7 @@ async function listPackages(options = {}) { } // lib/updateNpm.js +var import_node_process2 = __toESM(require("node:process"), 1); var core = __toESM(require_core(), 1); var import_exec6 = __toESM(require_exec(), 1); async function updateNpm(version2) { @@ -10932,7 +10935,7 @@ async function updateNpm(version2) { await (0, import_exec6.exec)("sudo", ["npm", ...cmdArgs]); } const { stdout: actualVersion } = await (0, import_exec6.getExecOutput)("npm", ["--version"]); - await (0, import_exec6.exec)("sudo", ["chown", "-R", `${process.env["USER"]}:`, `${process.env["HOME"]}/.config`]); + await (0, import_exec6.exec)("sudo", ["chown", "-R", `${import_node_process2.default.env["USER"]}:`, `${import_node_process2.default.env["HOME"]}/.config`]); return actualVersion.trim(); } @@ -10951,7 +10954,7 @@ async function filesChanged() { } } function getFromEnv(name) { - const value = process.env[name]; + const value = import_node_process3.default.env[name]; if (value) { return value; } diff --git a/lib/index.js b/lib/index.js index ba25fcf4..9723f3bc 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,3 +1,4 @@ +import process from "node:process"; import * as core from "@actions/core"; import { exec } from "@actions/exec"; import aggregateReport from "./aggregateReport.js"; diff --git a/lib/listPackages.js b/lib/listPackages.js index 5dbbacd7..95c60b7f 100644 --- a/lib/listPackages.js +++ b/lib/listPackages.js @@ -1,3 +1,4 @@ +import process from "node:process"; import { getExecOutput } from "@actions/exec"; import npmArgs from "./npmArgs.js"; diff --git a/lib/updateNpm.js b/lib/updateNpm.js index f792bef4..d9154edc 100644 --- a/lib/updateNpm.js +++ b/lib/updateNpm.js @@ -1,3 +1,4 @@ +import process from "node:process"; import * as core from "@actions/core"; import { exec, getExecOutput } from "@actions/exec"; import npmArgs from "./npmArgs.js";