unplugin-version-injector 1.1.1-alpha.2 → 1.1.1-alpha.4

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.
package/dist/core.js CHANGED
@@ -41,17 +41,23 @@ var import_node_fs = __toESM(require("fs"));
41
41
  var import_node_path = __toESM(require("path"));
42
42
  var import_node_url = require("url");
43
43
  var import_meta = {};
44
+ function getCurrentDir() {
45
+ try {
46
+ return import_node_path.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url));
47
+ } catch (e) {
48
+ return process.cwd();
49
+ }
50
+ }
44
51
  function getPackageVersion() {
52
+ var _a;
45
53
  try {
46
- const __filename = (0, import_node_url.fileURLToPath)(import_meta.url);
47
- const __dirname = import_node_path.default.dirname(__filename);
48
- let dir = __dirname;
54
+ let dir = getCurrentDir();
49
55
  while (dir !== import_node_path.default.parse(dir).root) {
50
56
  const pkgPath = import_node_path.default.join(dir, "package.json");
51
57
  if (import_node_fs.default.existsSync(pkgPath)) {
52
58
  const content = import_node_fs.default.readFileSync(pkgPath, "utf-8");
53
59
  const pkg = JSON.parse(content);
54
- return pkg.version || "0.0.0";
60
+ return (_a = pkg.version) != null ? _a : "0.0.0";
55
61
  }
56
62
  dir = import_node_path.default.dirname(dir);
57
63
  }
package/dist/core.mjs CHANGED
@@ -13,17 +13,23 @@ import fs from "node:fs";
13
13
  import path from "node:path";
14
14
  import { fileURLToPath } from "node:url";
15
15
  var import_meta = {};
16
+ function getCurrentDir() {
17
+ try {
18
+ return path.dirname(fileURLToPath(import_meta.url));
19
+ } catch (e) {
20
+ return process.cwd();
21
+ }
22
+ }
16
23
  function getPackageVersion() {
24
+ var _a;
17
25
  try {
18
- const __filename = fileURLToPath(import_meta.url);
19
- const __dirname = path.dirname(__filename);
20
- let dir = __dirname;
26
+ let dir = getCurrentDir();
21
27
  while (dir !== path.parse(dir).root) {
22
28
  const pkgPath = path.join(dir, "package.json");
23
29
  if (fs.existsSync(pkgPath)) {
24
30
  const content = fs.readFileSync(pkgPath, "utf-8");
25
31
  const pkg = JSON.parse(content);
26
- return pkg.version || "0.0.0";
32
+ return (_a = pkg.version) != null ? _a : "0.0.0";
27
33
  }
28
34
  dir = path.dirname(dir);
29
35
  }
package/dist/webpack.js CHANGED
@@ -42,17 +42,23 @@ var import_node_fs = __toESM(require("fs"));
42
42
  var import_node_path = __toESM(require("path"));
43
43
  var import_node_url = require("url");
44
44
  var import_meta = {};
45
+ function getCurrentDir() {
46
+ try {
47
+ return import_node_path.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url));
48
+ } catch (e) {
49
+ return process.cwd();
50
+ }
51
+ }
45
52
  function getPackageVersion() {
53
+ var _a;
46
54
  try {
47
- const __filename = (0, import_node_url.fileURLToPath)(import_meta.url);
48
- const __dirname = import_node_path.default.dirname(__filename);
49
- let dir = __dirname;
55
+ let dir = getCurrentDir();
50
56
  while (dir !== import_node_path.default.parse(dir).root) {
51
57
  const pkgPath = import_node_path.default.join(dir, "package.json");
52
58
  if (import_node_fs.default.existsSync(pkgPath)) {
53
59
  const content = import_node_fs.default.readFileSync(pkgPath, "utf-8");
54
60
  const pkg = JSON.parse(content);
55
- return pkg.version || "0.0.0";
61
+ return (_a = pkg.version) != null ? _a : "0.0.0";
56
62
  }
57
63
  dir = import_node_path.default.dirname(dir);
58
64
  }
package/dist/webpack.mjs CHANGED
@@ -13,17 +13,23 @@ import fs from "node:fs";
13
13
  import path from "node:path";
14
14
  import { fileURLToPath } from "node:url";
15
15
  var import_meta = {};
16
+ function getCurrentDir() {
17
+ try {
18
+ return path.dirname(fileURLToPath(import_meta.url));
19
+ } catch (e) {
20
+ return process.cwd();
21
+ }
22
+ }
16
23
  function getPackageVersion() {
24
+ var _a;
17
25
  try {
18
- const __filename = fileURLToPath(import_meta.url);
19
- const __dirname = path.dirname(__filename);
20
- let dir = __dirname;
26
+ let dir = getCurrentDir();
21
27
  while (dir !== path.parse(dir).root) {
22
28
  const pkgPath = path.join(dir, "package.json");
23
29
  if (fs.existsSync(pkgPath)) {
24
30
  const content = fs.readFileSync(pkgPath, "utf-8");
25
31
  const pkg = JSON.parse(content);
26
- return pkg.version || "0.0.0";
32
+ return (_a = pkg.version) != null ? _a : "0.0.0";
27
33
  }
28
34
  dir = path.dirname(dir);
29
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-version-injector",
3
- "version": "1.1.1-alpha.2",
3
+ "version": "1.1.1-alpha.4",
4
4
  "author": "Nian Yi <nianyi778@gmail.com>",
5
5
  "license": "MIT",
6
6
  "description": "A universal plugin to inject version and build time into HTML (supports Webpack, Vite, Rollup)",