@0x-jerry/x 2.3.3 → 2.3.5

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 (3) hide show
  1. package/dist/xr.js +11 -11
  2. package/package.json +18 -16
  3. package/readme.md +19 -19
package/dist/xr.js CHANGED
@@ -11,7 +11,7 @@ import path, { join, resolve } from "path";
11
11
  import pc from "picocolors";
12
12
  import jsonc from "jsonc-parser";
13
13
  import { readFile, readdir } from "fs/promises";
14
- import { statSync } from "fs";
14
+ import { existsSync } from "fs";
15
15
  var { red, cyan } = pc;
16
16
  async function runScript(command, params = []) {
17
17
  const [scriptExecuteContent, allScripts] = await getScriptContent(command);
@@ -29,20 +29,16 @@ async function runScript(command, params = []) {
29
29
  function makeEnv() {
30
30
  const cwd = process.cwd();
31
31
  const env = process.env;
32
- const envPaths = [];
32
+ const envPaths = process.env.PATH?.split(path.delimiter) || [];
33
33
  let dir = cwd;
34
34
  do {
35
- const PATH2 = join(dir, "node_modules", ".bin");
36
- try {
37
- statSync(PATH2);
38
- envPaths.push(PATH2);
39
- } catch (_error) {
35
+ const binPath = join(dir, "node_modules", ".bin");
36
+ if (existsSync(binPath)) {
37
+ envPaths.push(binPath);
40
38
  }
41
39
  dir = resolve(dir, "..");
42
40
  } while (dir !== resolve(dir, ".."));
43
- const separator = path.delimiter;
44
- const PATH = envPaths.join(separator);
45
- env.PATH = [process.env.PATH || "", PATH].filter(Boolean).join(separator);
41
+ env.PATH = envPaths.join(path.delimiter);
46
42
  return env;
47
43
  }
48
44
  async function getPackageScripts() {
@@ -120,5 +116,9 @@ ins.type("command", async () => {
120
116
  });
121
117
  async function defaultAction(_, arg) {
122
118
  const [command, ...params] = arg._;
123
- await runScript(command, params);
119
+ try {
120
+ await runScript(command, params);
121
+ } catch (error) {
122
+ console.error(error);
123
+ }
124
124
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@0x-jerry/x",
3
- "version": "2.3.3",
4
- "main": "dist/index.js",
3
+ "version": "2.3.5",
4
+ "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/0x-jerry/x.git"
@@ -11,7 +11,9 @@
11
11
  "type": "module",
12
12
  "publishConfig": {
13
13
  "access": "public",
14
- "registry": "https://registry.npmjs.com"
14
+ "registry": "https://registry.npmjs.org",
15
+ "main": "dist/index.js",
16
+ "typings": "dist/index.d.ts"
15
17
  },
16
18
  "files": [
17
19
  "dist"
@@ -21,6 +23,16 @@
21
23
  "xn": "dist/xn.js",
22
24
  "x": "dist/x.js"
23
25
  },
26
+ "scripts": {
27
+ "build": "tsup",
28
+ "dev:xr": "tsx src/xr.ts",
29
+ "dev:xn": "tsx src/xn.ts",
30
+ "dev:x": "tsx src/x.ts",
31
+ "test": "vitest",
32
+ "ci:test": "vitest run",
33
+ "prepublishOnly": "npm run build",
34
+ "release": "x-release"
35
+ },
24
36
  "tsup": {
25
37
  "entry": [
26
38
  "src/xr.ts",
@@ -35,7 +47,7 @@
35
47
  },
36
48
  "dependencies": {
37
49
  "@0x-jerry/silver": "^0.1.5",
38
- "@0x-jerry/utils": "^2.2.2",
50
+ "@0x-jerry/utils": "^2.2.5",
39
51
  "decompress": "^4.2.1",
40
52
  "fs-extra": "^11.2.0",
41
53
  "global-agent": "^3.0.0",
@@ -46,7 +58,7 @@
46
58
  "prompts": "^2.4.2"
47
59
  },
48
60
  "devDependencies": {
49
- "@0x-jerry/x-release": "^1.0.1",
61
+ "@0x-jerry/x-release": "^2.0.1",
50
62
  "@types/decompress": "^4.2.7",
51
63
  "@types/fs-extra": "^11.0.4",
52
64
  "@types/global-agent": "^2.1.3",
@@ -57,15 +69,5 @@
57
69
  "tsx": "^4.9.3",
58
70
  "typescript": "^5.4.5",
59
71
  "vitest": "^1.6.0"
60
- },
61
- "scripts": {
62
- "build": "tsup",
63
- "dev:xr": "tsx src/xr.ts",
64
- "dev:xn": "tsx src/xn.ts",
65
- "dev:x": "tsx src/x.ts",
66
- "test": "vitest",
67
- "ci:test": "vitest run",
68
- "release": "x-release"
69
- },
70
- "typings": "dist/index.d.ts"
72
+ }
71
73
  }
package/readme.md CHANGED
@@ -1,19 +1,19 @@
1
- # X
2
-
3
- Some useful command for myself.
4
-
5
- ## Install
6
-
7
- ```sh
8
- npm i -g @0x-jerry/x
9
- ```
10
-
11
- ## Command Completions
12
-
13
- Add this code to `~/.zshrc`
14
-
15
- ```zsh
16
- source <(x completions)
17
- source <(xr completions)
18
- source <(xn completions)
19
- ```
1
+ # X
2
+
3
+ Some useful command for myself.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm i -g @0x-jerry/x
9
+ ```
10
+
11
+ ## Command Completions
12
+
13
+ Add this code to `~/.zshrc`
14
+
15
+ ```zsh
16
+ source <(x completions)
17
+ source <(xr completions)
18
+ source <(xn completions)
19
+ ```