@talex-touch/utils 1.0.12 → 1.0.13

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/common/env-tool.ts +15 -4
  2. package/package.json +1 -1
@@ -3,11 +3,11 @@ import { exec, ExecException } from 'child_process';
3
3
  export interface IGlobalPkgResult {
4
4
  exist: boolean
5
5
  error?: ExecException
6
- name: string
7
- version: string
6
+ name?: string
7
+ version?: string
8
8
  }
9
9
 
10
- export function checkGlobalPackageExist(packageName: string) {
10
+ export function checkGlobalPackageExist(packageName: string): Promise<IGlobalPkgResult> {
11
11
  return new Promise((resolve, reject) => {
12
12
  exec(`npm list -g ${packageName}`, (error, stdout, stderr) => {
13
13
  if (error) {
@@ -39,8 +39,19 @@ export function checkGlobalPackageExist(packageName: string) {
39
39
 
40
40
  resolve({
41
41
  exist: false
42
- })
42
+ } as IGlobalPkgResult)
43
43
 
44
44
  });
45
45
  })
46
+ }
47
+
48
+ // Check npm version
49
+ export function getNpmVersion(): Promise<string | null> {
50
+ return new Promise((resolve) => {
51
+ exec(`npm --version`, (error, stdout, stderr) => {
52
+ if (error || stderr) resolve(null)
53
+
54
+ resolve(stdout.trim())
55
+ })
56
+ })
46
57
  }
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "module": "./index.ts",
6
6
  "license": "MPL-2.0",
7
7
  "private": false,
8
- "version": "1.0.12",
8
+ "version": "1.0.13",
9
9
  "scripts": {
10
10
  "publish": "npm publish --access public"
11
11
  },