diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 482976de74a..3763a7467cb 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -71,6 +71,19 @@ jobs: with: fetch-depth: 0 + - name: Add workspace to Defender exclusions + if: matrix.os == 'windows-latest' + run: | + Add-MpPreference -ExclusionPath "${{ github.workspace }}" + + Add-MpPreference -ExclusionProcess "node.exe" + + $npmCache = (npm config get cache) + Add-MpPreference -ExclusionPath $npmCache + + Set-MpPreference -DisableRealtimeMonitoring $true + shell: powershell + - name: Using Node.js v${{ matrix.node-version }} uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 with: diff --git a/.gitignore b/.gitignore index 0cd9e98f062..aaf111b65be 100644 --- a/.gitignore +++ b/.gitignore @@ -59,6 +59,7 @@ packages/**/yarn.lock # test output files test/js/* +test/create-webpack-app-testing/* test/**/bin/ test/**/**/bin/ test/**/**/**/bin/ diff --git a/eslint.config.mjs b/eslint.config.mjs index 4021eee7921..9c51bae9331 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -5,6 +5,7 @@ import configs from "eslint-config-webpack/configs.js"; export default defineConfig([ globalIgnores([ "packages/*/lib/**/*", + "test/**/create-webpack-app-testing/**/*", "test/**/dist/**/*", "test/**/bin/**/*", "test/**/binary/**/*", diff --git a/test/create-webpack-app/init/init.test.js b/test/create-webpack-app/init/init.test.js index 02c48667cca..d9bf1072d67 100644 --- a/test/create-webpack-app/init/init.test.js +++ b/test/create-webpack-app/init/init.test.js @@ -1,6 +1,5 @@ const { existsSync, mkdirSync, readFileSync, writeFileSync } = require("node:fs"); const { cp } = require("node:fs/promises"); -const os = require("node:os"); const path = require("node:path"); const { join, resolve } = require("node:path"); const { createPathDependentUtils, isWindows, uniqueDirectoryForTest } = require("../test.utils"); @@ -149,7 +148,11 @@ describe("create-webpack-app cli", () => { }); it("should generate folders if non existing generation path is given", async () => { - const assetsPath = path.resolve(os.tmpdir(), Date.now().toString()); + const assetsPath = path.resolve( + __dirname, + "../create-webpack-app-testing", + Date.now().toString(), + ); const { stdout } = await run(__dirname, ["init", assetsPath, "--force"]); expect(stdout).toContain("Project has been initialised with webpack!"); diff --git a/test/utils/test-utils.js b/test/utils/test-utils.js index a0692bda71e..d2f16f89c1e 100644 --- a/test/utils/test-utils.js +++ b/test/utils/test-utils.js @@ -2,7 +2,6 @@ const { exec } = require("node:child_process"); const fs = require("node:fs"); -const os = require("node:os"); const path = require("node:path"); const { stripVTControlCharacters } = require("node:util"); const concat = require("concat-stream"); @@ -373,10 +372,10 @@ const uuid = (size = 21) => { }; const uniqueDirectoryForTest = async () => { - const result = path.resolve(os.tmpdir(), uuid()); + const result = path.resolve(path.resolve(__dirname, "../create-webpack-app-testing"), uuid()); if (!fs.existsSync(result)) { - fs.mkdirSync(result); + fs.mkdirSync(result, { recursive: true }); } return result;