Skip to content

Commit e0b2f07

Browse files
test: improve
1 parent 5328fcb commit e0b2f07

File tree

24 files changed

+535
-139
lines changed

24 files changed

+535
-139
lines changed

.c8rc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"all": true,
3-
"clean": false,
3+
"clean": true,
44
"root": ".",
55
"include": ["packages/*/src/**/*.ts"],
6+
"exclude": ["packages/*/src/**/types.ts"],
67
"reporter": ["text", "html", "lcov"],
78
"exclude-after-remap": true
89
}

.github/workflows/nodejs.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ jobs:
9595
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
9696
with:
9797
token: ${{ secrets.CODECOV_TOKEN }}
98-
verbose: true
9998

10099
smoketests:
101100
name: Smoketests
@@ -131,3 +130,8 @@ jobs:
131130

132131
- name: Run smoketests
133132
run: npm run test:smoketests
133+
134+
- name: Upload coverage to Codecov
135+
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
136+
with:
137+
token: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# Node dependencies
1717
node_modules
1818
test/**/node_modules
19+
!test/external-command/node_modules
1920

2021
# Lock files
2122
yarn.lock

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"./packages/*"
2424
],
2525
"scripts": {
26-
"clean": "del-cli \"*.tsbuildinfo\" \"packages/**/*.tsbuildinfo\" \"packages/*/lib/!(*.tpl)\" \"**/.yo-rc.json\"",
26+
"clean": "del-cli \"*.tsbuildinfo\" \"packages/**/*.tsbuildinfo\" \"packages/*/lib/!(*.tpl)\"",
2727
"prebuild": "npm run clean",
2828
"prebuild:ci": "npm run clean && node ./scripts/setup-build.js",
2929
"build": "tsc --build",
@@ -38,8 +38,8 @@
3838
"fix:code": "npm run lint:code -- --fix",
3939
"pretest": "npm run build && npm run lint",
4040
"test": "npm run test:base",
41-
"test:base": "node --experimental-vm-modules --enable-source-maps ./node_modules/jest-cli/bin/jest",
42-
"test:smoketests": "c8 node smoketests",
41+
"test:base": "node --experimental-vm-modules --enable-source-maps ./node_modules/jest-cli/bin/jest --workerThreads",
42+
"test:smoketests": "c8 node --enable-source-maps smoketests/index.js",
4343
"test:coverage": "c8 npm run test:base",
4444
"update:docs": "node ./scripts/update-docs",
4545
"version": "node ./node_modules/.bin/changeset version && node ./scripts/sync-changelogs.js",

packages/create-webpack-app/src/utils/generate-files.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,6 @@ async function checkAndPrepareContent(config: AddConfig, isTemplate: boolean): P
162162
return { status: "identical", content: existingFileContent };
163163
}
164164

165-
// Prompt for conflict resolution
166-
const tempFilePath = path.join("/tmp", `temp_${path.basename(config.path)}`);
167-
await fs.writeFile(tempFilePath, newContent || "");
168-
169165
let userChoice: Result | undefined;
170166
while (!userChoice) {
171167
const action = await expand({
@@ -194,7 +190,14 @@ async function checkAndPrepareContent(config: AddConfig, isTemplate: boolean): P
194190
case "overwrite_all":
195191
globalConfig.overwriteAll = true;
196192
return { status: "overwrite", content: newContent };
197-
case "diff":
193+
case "diff": {
194+
// Prompt for conflict resolution
195+
const tempFilePath = path.join(
196+
config.data!.projectPath as string,
197+
`.temp_${path.basename(config.path)}`,
198+
);
199+
await fs.writeFile(tempFilePath, newContent || "");
200+
198201
if (!isTemplate && Buffer.isBuffer(existingFileContent)) {
199202
const existingStats = await fs.stat(config.path);
200203
const newStats = await fs.stat(tempFilePath);
@@ -219,17 +222,18 @@ async function checkAndPrepareContent(config: AddConfig, isTemplate: boolean): P
219222
} else {
220223
await getDiff(config.path, tempFilePath);
221224
}
225+
226+
await fs.unlink(tempFilePath).catch(() => {
227+
logger.warn(`Failed to delete temporary file: ${tempFilePath}`);
228+
});
222229
break;
230+
}
223231
case "abort":
224232
logger.error("Aborting process...");
225233
process.exit(1);
226234
}
227235
}
228236

229-
await fs.unlink(tempFilePath).catch(() => {
230-
logger.warn(`Failed to delete temporary file: ${tempFilePath}`);
231-
});
232-
233237
return userChoice;
234238
}
235239
// If the file doesn't exist, create it
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
{
22
"extends": "../../tsconfig.json",
3-
"exclude": ["src/utils/__tests__"],
43
"compilerOptions": {
54
"outDir": "lib",
65
"rootDir": "src"
76
},
8-
"include": ["./src"],
9-
"references": [
10-
{
11-
"path": "../webpack-cli"
12-
}
13-
]
7+
"include": ["./src"]
148
}

0 commit comments

Comments
 (0)