umi 4.0.32 → 4.0.33

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/cli/fork.js +26 -2
  2. package/package.json +10 -10
package/dist/cli/fork.js CHANGED
@@ -23,6 +23,7 @@ __export(fork_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(fork_exports);
25
25
  var import_child_process = require("child_process");
26
+ var import_utils = require("@umijs/utils");
26
27
  var usedPorts = [];
27
28
  function start({ scriptPath }) {
28
29
  const execArgv = process.execArgv.slice(0);
@@ -50,13 +51,36 @@ function start({ scriptPath }) {
50
51
  if (type === "RESTART") {
51
52
  child.kill();
52
53
  if (payload == null ? void 0 : payload.port) {
53
- process.env.PORT = payload.port;
54
+ utilPortValid(payload.port, 20, () => {
55
+ process.env.PORT = payload.port;
56
+ start({ scriptPath });
57
+ });
58
+ } else {
59
+ start({ scriptPath });
54
60
  }
55
- start({ scriptPath });
56
61
  }
57
62
  (_a = process.send) == null ? void 0 : _a.call(process, data);
58
63
  });
59
64
  return child;
60
65
  }
66
+ function utilPortValid(port, totalTry, callback) {
67
+ import_utils.portfinder.getPort({ startPort: port }, (err, findPort) => {
68
+ if (err)
69
+ callback(err);
70
+ else {
71
+ if (findPort === port) {
72
+ callback();
73
+ } else {
74
+ if (totalTry > 0) {
75
+ setTimeout(() => {
76
+ utilPortValid(port, totalTry - 1, callback);
77
+ }, 100);
78
+ } else {
79
+ callback(new Error(`Port ${port} is occupied`));
80
+ }
81
+ }
82
+ }
83
+ });
84
+ }
61
85
  // Annotate the CommonJS export names for ESM import in node:
62
86
  0 && (module.exports = {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "umi",
3
- "version": "4.0.32",
3
+ "version": "4.0.33",
4
4
  "description": "umi",
5
5
  "homepage": "https://github.com/umijs/umi/tree/master/packages/umi#readme",
6
6
  "bugs": "https://github.com/umijs/umi/issues",
@@ -38,15 +38,15 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@babel/runtime": "7.18.9",
41
- "@umijs/bundler-utils": "4.0.32",
42
- "@umijs/bundler-webpack": "4.0.32",
43
- "@umijs/core": "4.0.32",
44
- "@umijs/lint": "4.0.32",
45
- "@umijs/preset-umi": "4.0.32",
46
- "@umijs/renderer-react": "4.0.32",
47
- "@umijs/server": "4.0.32",
48
- "@umijs/test": "4.0.32",
49
- "@umijs/utils": "4.0.32",
41
+ "@umijs/bundler-utils": "4.0.33",
42
+ "@umijs/bundler-webpack": "4.0.33",
43
+ "@umijs/core": "4.0.33",
44
+ "@umijs/lint": "4.0.33",
45
+ "@umijs/preset-umi": "4.0.33",
46
+ "@umijs/renderer-react": "4.0.33",
47
+ "@umijs/server": "4.0.33",
48
+ "@umijs/test": "4.0.33",
49
+ "@umijs/utils": "4.0.33",
50
50
  "prettier-plugin-organize-imports": "^2.3.4",
51
51
  "prettier-plugin-packagejson": "^2.2.17"
52
52
  },