@rspack-canary/test-tools 1.6.8-canary-ea281acb-20251211080551 → 1.6.8-canary-19c6cd71-20251212173633

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/case/watch.js +17 -11
  2. package/package.json +2 -2
@@ -8,8 +8,8 @@ exports.createWatchStepProcessor = createWatchStepProcessor;
8
8
  exports.createWatchCase = createWatchCase;
9
9
  exports.getWatchRunnerKey = getWatchRunnerKey;
10
10
  exports.createWatchRunner = createWatchRunner;
11
- const node_fs_1 = __importDefault(require("node:fs"));
12
11
  const node_path_1 = __importDefault(require("node:path"));
12
+ const fs_extra_1 = __importDefault(require("fs-extra"));
13
13
  const webpack_merge_1 = __importDefault(require("webpack-merge"));
14
14
  const compiler_1 = require("../compiler");
15
15
  const helper_1 = require("../helper");
@@ -58,8 +58,14 @@ function createWatchInitialProcessor(name, tempDir, step, watchState, { incremen
58
58
  },
59
59
  build: async (context) => {
60
60
  const compiler = context.getCompiler();
61
- node_fs_1.default.mkdirSync(watchContext.tempDir, { recursive: true });
61
+ fs_extra_1.default.mkdirSync(watchContext.tempDir, { recursive: true });
62
62
  (0, copyDiff_1.default)(node_path_1.default.join(context.getSource(), watchContext.step), watchContext.tempDir, true);
63
+ const pkgJsonFile = node_path_1.default.join(watchContext.tempDir, "package.json");
64
+ if (!fs_extra_1.default.existsSync(pkgJsonFile)) {
65
+ fs_extra_1.default.writeJsonSync(pkgJsonFile, { name, version: "0.0.1" });
66
+ const longTimeAgo = Date.now() - 1000 * 60 * 60 * 24;
67
+ fs_extra_1.default.utimesSync(pkgJsonFile, Date.now() - longTimeAgo, Date.now() - longTimeAgo);
68
+ }
63
69
  const task = new Promise((resolve, reject) => {
64
70
  compiler.getEmitter().once(compiler_1.ECompilerEvent.Build, (e, stats) => {
65
71
  if (e)
@@ -88,7 +94,7 @@ function createWatchInitialProcessor(name, tempDir, step, watchState, { incremen
88
94
  const checkStats = testConfig.checkStats || (() => true);
89
95
  if (stats) {
90
96
  if (testConfig.writeStatsOuptut) {
91
- node_fs_1.default.writeFileSync(node_path_1.default.join(context.getDist(), "stats.txt"), stats.toString({
97
+ fs_extra_1.default.writeFileSync(node_path_1.default.join(context.getDist(), "stats.txt"), stats.toString({
92
98
  preset: "verbose",
93
99
  colors: false
94
100
  }), "utf-8");
@@ -127,10 +133,10 @@ function createWatchInitialProcessor(name, tempDir, step, watchState, { incremen
127
133
  }
128
134
  }
129
135
  if (testConfig.writeStatsJson) {
130
- node_fs_1.default.writeFileSync(node_path_1.default.join(context.getDist(), "stats.json"), JSON.stringify(getJsonStats(), null, 2), "utf-8");
136
+ fs_extra_1.default.writeFileSync(node_path_1.default.join(context.getDist(), "stats.json"), JSON.stringify(getJsonStats(), null, 2), "utf-8");
131
137
  }
132
- if (node_fs_1.default.existsSync(context.getSource(`${watchContext.step}/errors.js`)) ||
133
- node_fs_1.default.existsSync(context.getSource(`${watchContext.step}/warnings.js`)) ||
138
+ if (fs_extra_1.default.existsSync(context.getSource(`${watchContext.step}/errors.js`)) ||
139
+ fs_extra_1.default.existsSync(context.getSource(`${watchContext.step}/warnings.js`)) ||
134
140
  stats.hasErrors() ||
135
141
  stats.hasWarnings()) {
136
142
  const statsJson = stats.toJson({
@@ -147,15 +153,15 @@ function createWatchInitialProcessor(name, tempDir, step, watchState, { incremen
147
153
  await (0, checkArrayExpectation_1.default)(node_path_1.default.join(context.getSource(), watchContext.step), { errors }, "error", "errors", "Error", options);
148
154
  await (0, checkArrayExpectation_1.default)(node_path_1.default.join(context.getSource(), watchContext.step), { warnings }, "warning", "warnings", "Warning", options);
149
155
  // clear error if checked
150
- if (node_fs_1.default.existsSync(context.getSource("errors.js"))) {
156
+ if (fs_extra_1.default.existsSync(context.getSource("errors.js"))) {
151
157
  context.clearError();
152
158
  }
153
159
  // check hash
154
160
  if (testConfig.writeStatsOuptut) {
155
- node_fs_1.default.renameSync(node_path_1.default.join(context.getDist(), "stats.txt"), node_path_1.default.join(context.getDist(), `stats.${watchContext.step}.txt`));
161
+ fs_extra_1.default.renameSync(node_path_1.default.join(context.getDist(), "stats.txt"), node_path_1.default.join(context.getDist(), `stats.${watchContext.step}.txt`));
156
162
  }
157
163
  if (testConfig.writeStatsJson) {
158
- node_fs_1.default.renameSync(node_path_1.default.join(context.getDist(), "stats.json"), node_path_1.default.join(context.getDist(), `stats.${watchContext.step}.json`));
164
+ fs_extra_1.default.renameSync(node_path_1.default.join(context.getDist(), "stats.json"), node_path_1.default.join(context.getDist(), `stats.${watchContext.step}.json`));
159
165
  }
160
166
  },
161
167
  after: async (context) => {
@@ -206,10 +212,10 @@ const creator = new creator_1.BasicCaseCreator({
206
212
  describe: false,
207
213
  steps: ({ name, src, temp }) => {
208
214
  const watchState = {};
209
- const runs = node_fs_1.default
215
+ const runs = fs_extra_1.default
210
216
  .readdirSync(src)
211
217
  .sort()
212
- .filter(name => node_fs_1.default.statSync(node_path_1.default.join(src, name)).isDirectory())
218
+ .filter(name => fs_extra_1.default.statSync(node_path_1.default.join(src, name)).isDirectory())
213
219
  .map(name => ({ name }));
214
220
  return runs.map((run, index) => index === 0
215
221
  ? createWatchInitialProcessor(name, temp, run.name, watchState)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack-canary/test-tools",
3
- "version": "1.6.8-canary-ea281acb-20251211080551",
3
+ "version": "1.6.8-canary-19c6cd71-20251212173633",
4
4
  "license": "MIT",
5
5
  "description": "Test tools for rspack",
6
6
  "main": "dist/index.js",
@@ -65,7 +65,7 @@
65
65
  "@types/jsdom": "^21.1.7",
66
66
  "typescript": "^5.9.3",
67
67
  "wast-loader": "^1.14.1",
68
- "@rspack/core": "npm:@rspack-canary/core@1.6.8-canary-ea281acb-20251211080551"
68
+ "@rspack/core": "npm:@rspack-canary/core@1.6.8-canary-19c6cd71-20251212173633"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "@rspack/core": ">=1.0.0"