@vanillaes/esmtk 1.2.0 → 1.2.2
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/bin/commands/bundle.js +7 -4
- package/bin/commands/clean.js +2 -1
- package/bin/commands/commonjs.js +7 -4
- package/bin/commands/cp.js +2 -0
- package/bin/commands/init.js +24 -11
- package/bin/commands/lint.js +4 -2
- package/bin/commands/minify.js +7 -4
- package/bin/commands/preview.js +1 -1
- package/bin/commands/test.js +14 -4
- package/bin/commands/type.js +7 -4
- package/bin/commands/typings.js +7 -4
- package/package.json +2 -2
- package/src/cp.js +33 -18
- package/src/rm.js +16 -11
- package/src/util.js +6 -4
package/bin/commands/bundle.js
CHANGED
|
@@ -12,14 +12,16 @@ export async function bundle (input, output, options) {
|
|
|
12
12
|
if (!npmExists) {
|
|
13
13
|
console.error('npm not found')
|
|
14
14
|
console.error('is node installed?')
|
|
15
|
-
process.
|
|
15
|
+
process.exitCode = 1
|
|
16
|
+
return
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
const esbuildExists = await installed('esbuild')
|
|
19
20
|
if (!esbuildExists) {
|
|
20
21
|
console.error('esbuild not found')
|
|
21
22
|
console.error('esbuild can be installed with `npm i -g esbuild`')
|
|
22
|
-
process.
|
|
23
|
+
process.exitCode = 1
|
|
24
|
+
return
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
const args = []
|
|
@@ -34,7 +36,8 @@ export async function bundle (input, output, options) {
|
|
|
34
36
|
spawn('esbuild', args, {
|
|
35
37
|
cwd: process.cwd(),
|
|
36
38
|
stdio: ['pipe', process.stdout, process.stderr]
|
|
37
|
-
}).on('error',
|
|
38
|
-
console.error(
|
|
39
|
+
}).on('error', error => {
|
|
40
|
+
console.error(error)
|
|
41
|
+
process.exitCode = 1
|
|
39
42
|
})
|
|
40
43
|
}
|
package/bin/commands/clean.js
CHANGED
package/bin/commands/commonjs.js
CHANGED
|
@@ -12,14 +12,16 @@ export async function commonjs (input, output, options) {
|
|
|
12
12
|
if (!npmExists) {
|
|
13
13
|
console.error('npm not found')
|
|
14
14
|
console.error('is node installed?')
|
|
15
|
-
process.
|
|
15
|
+
process.exitCode = 1
|
|
16
|
+
return
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
const esbuildExists = await installed('esbuild')
|
|
19
20
|
if (!esbuildExists) {
|
|
20
21
|
console.error('esbuild not found')
|
|
21
22
|
console.error('esbuild can be installed with `npm i -g esbuild`')
|
|
22
|
-
process.
|
|
23
|
+
process.exitCode = 1
|
|
24
|
+
return
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
const args = []
|
|
@@ -34,7 +36,8 @@ export async function commonjs (input, output, options) {
|
|
|
34
36
|
spawn('esbuild', args, {
|
|
35
37
|
cwd: process.cwd(),
|
|
36
38
|
stdio: ['pipe', process.stdout, process.stderr]
|
|
37
|
-
}).on('error',
|
|
38
|
-
console.error(
|
|
39
|
+
}).on('error', error => {
|
|
40
|
+
console.error(error)
|
|
41
|
+
process.exitCode = 1
|
|
39
42
|
})
|
|
40
43
|
}
|
package/bin/commands/cp.js
CHANGED
package/bin/commands/init.js
CHANGED
|
@@ -17,22 +17,37 @@ export async function init (options) {
|
|
|
17
17
|
if (!npmExists) {
|
|
18
18
|
console.error('npm not found')
|
|
19
19
|
console.error('is node installed?')
|
|
20
|
-
process.
|
|
20
|
+
process.exitCode = 1
|
|
21
|
+
return
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
const gitExists = await which('git')
|
|
24
25
|
if (!gitExists) {
|
|
25
26
|
console.error('git not found')
|
|
26
27
|
console.error('is git installed?')
|
|
27
|
-
process.
|
|
28
|
+
process.exitCode = 1
|
|
29
|
+
return
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
// defaults
|
|
31
33
|
const DIR = process.cwd()
|
|
32
34
|
const DIRNAME = basename(process.cwd())
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
let REPOSITORY
|
|
36
|
+
let USERNAME
|
|
37
|
+
let EMAIL
|
|
38
|
+
try {
|
|
39
|
+
REPOSITORY = await fetchGitRepository()
|
|
40
|
+
USERNAME = gitExists ? await fetchGitUser() : ''
|
|
41
|
+
EMAIL = gitExists ? await fetchGitEmail() : ''
|
|
42
|
+
} catch (error) {
|
|
43
|
+
if (error instanceof Error) {
|
|
44
|
+
console.log(error.message)
|
|
45
|
+
} else {
|
|
46
|
+
console.error(`Unexpected error: ${error}`)
|
|
47
|
+
}
|
|
48
|
+
process.exitCode = 1
|
|
49
|
+
return
|
|
50
|
+
}
|
|
36
51
|
|
|
37
52
|
const program = createInterface({ input: stdin, output: stdout })
|
|
38
53
|
|
|
@@ -116,8 +131,7 @@ async function ask (program, prompt, defaultValue) {
|
|
|
116
131
|
async function fetchGitUser () {
|
|
117
132
|
const { stdout, stderr } = await execAsync('git config --get user.name')
|
|
118
133
|
if (stderr) {
|
|
119
|
-
|
|
120
|
-
process.exit(1)
|
|
134
|
+
throw new Error(`exec error: ${stderr}`)
|
|
121
135
|
}
|
|
122
136
|
console.log(`${stdout}`.trim())
|
|
123
137
|
return `${stdout}`.trim()
|
|
@@ -130,18 +144,17 @@ async function fetchGitUser () {
|
|
|
130
144
|
async function fetchGitEmail () {
|
|
131
145
|
const { stdout, stderr } = await execAsync('git config --get user.email')
|
|
132
146
|
if (stderr) {
|
|
133
|
-
|
|
134
|
-
process.exit(1)
|
|
147
|
+
throw new Error(`exec error: ${stderr}`)
|
|
135
148
|
}
|
|
136
149
|
console.log(`${stdout}`.trim())
|
|
137
150
|
return `${stdout}`.trim()
|
|
138
151
|
}
|
|
139
152
|
|
|
140
153
|
/**
|
|
141
|
-
*
|
|
154
|
+
* Fetch the repository name from .git/config
|
|
142
155
|
* @returns {Promise<string>} the repository name
|
|
143
156
|
*/
|
|
144
|
-
async function
|
|
157
|
+
async function fetchGitRepository () {
|
|
145
158
|
const config = join(process.cwd(), '.git', 'config')
|
|
146
159
|
const exists = await fileExists(config)
|
|
147
160
|
if (!exists) {
|
package/bin/commands/lint.js
CHANGED
|
@@ -16,8 +16,9 @@ export async function lint (options) {
|
|
|
16
16
|
const child = spawn(BIN_PATH, args, {
|
|
17
17
|
cwd: process.cwd(),
|
|
18
18
|
stdio: ['pipe', 'pipe', 'pipe']
|
|
19
|
-
}).on('error',
|
|
20
|
-
console.error(`${
|
|
19
|
+
}).on('error', error => {
|
|
20
|
+
console.error(`${error}`)
|
|
21
|
+
process.exitCode = 1
|
|
21
22
|
})
|
|
22
23
|
|
|
23
24
|
child.stdout.on('data', (data) => {
|
|
@@ -30,5 +31,6 @@ export async function lint (options) {
|
|
|
30
31
|
} else {
|
|
31
32
|
process.stderr.write(`${data}`)
|
|
32
33
|
}
|
|
34
|
+
process.exitCode = 1
|
|
33
35
|
})
|
|
34
36
|
}
|
package/bin/commands/minify.js
CHANGED
|
@@ -12,14 +12,16 @@ export async function minify (input, output, options) {
|
|
|
12
12
|
if (!npmExists) {
|
|
13
13
|
console.error('npm not found')
|
|
14
14
|
console.error('is node installed?')
|
|
15
|
-
process.
|
|
15
|
+
process.exitCode = 1
|
|
16
|
+
return
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
const esbuildExists = await installed('esbuild')
|
|
19
20
|
if (!esbuildExists) {
|
|
20
21
|
console.error('esbuild not found')
|
|
21
22
|
console.error('esbuild can be installed with `npm i -g esbuild`')
|
|
22
|
-
process.
|
|
23
|
+
process.exitCode = 1
|
|
24
|
+
return
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
const args = []
|
|
@@ -38,7 +40,8 @@ export async function minify (input, output, options) {
|
|
|
38
40
|
spawn('esbuild', args, {
|
|
39
41
|
cwd: process.cwd(),
|
|
40
42
|
stdio: ['pipe', process.stdout, process.stderr]
|
|
41
|
-
}).on('error',
|
|
42
|
-
console.error(
|
|
43
|
+
}).on('error', error => {
|
|
44
|
+
console.error(error)
|
|
45
|
+
process.exitCode = 1
|
|
43
46
|
})
|
|
44
47
|
}
|
package/bin/commands/preview.js
CHANGED
|
@@ -17,7 +17,7 @@ export async function preview (options) {
|
|
|
17
17
|
let files = await match('**/*', options.cwd, ignore)
|
|
18
18
|
if (files.length === 0) {
|
|
19
19
|
console.log('preview: no files found')
|
|
20
|
-
|
|
20
|
+
return
|
|
21
21
|
}
|
|
22
22
|
files = files
|
|
23
23
|
.filter(path => statSync(path).isFile())
|
package/bin/commands/test.js
CHANGED
|
@@ -21,10 +21,20 @@ export async function test (glob, options) {
|
|
|
21
21
|
args.push('--watch')
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
spawn('node', args, {
|
|
24
|
+
const child = spawn('node', args, {
|
|
25
25
|
cwd: process.cwd(),
|
|
26
|
-
stdio: ['pipe',
|
|
27
|
-
}).on('error',
|
|
28
|
-
console.error(
|
|
26
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
27
|
+
}).on('error', error => {
|
|
28
|
+
console.error(error)
|
|
29
|
+
process.exitCode = 1
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
child.stdout.on('data', (data) => {
|
|
33
|
+
process.stdout.write(`${data}`)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
child.stderr.on('data', (data) => {
|
|
37
|
+
process.stderr.write(`${data}`)
|
|
38
|
+
process.exitCode = 1
|
|
29
39
|
})
|
|
30
40
|
}
|
package/bin/commands/type.js
CHANGED
|
@@ -11,14 +11,16 @@ export async function type (entry, options) {
|
|
|
11
11
|
if (!npmExists) {
|
|
12
12
|
console.error('npm not found')
|
|
13
13
|
console.error('is node installed?')
|
|
14
|
-
process.
|
|
14
|
+
process.exitCode = 1
|
|
15
|
+
return
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
const esbuildExists = await installed('typescript')
|
|
18
19
|
if (!esbuildExists) {
|
|
19
20
|
console.error('typescript not found')
|
|
20
21
|
console.error('typescript can be installed with `npm i -g typescript`')
|
|
21
|
-
process.
|
|
22
|
+
process.exitCode = 1
|
|
23
|
+
return
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
const args = []
|
|
@@ -44,7 +46,8 @@ export async function type (entry, options) {
|
|
|
44
46
|
spawn('tsc', args, {
|
|
45
47
|
cwd: process.cwd(),
|
|
46
48
|
stdio: ['pipe', process.stdout, process.stderr]
|
|
47
|
-
}).on('error',
|
|
48
|
-
console.error(
|
|
49
|
+
}).on('error', error => {
|
|
50
|
+
console.error(error)
|
|
51
|
+
process.exitCode = 1
|
|
49
52
|
})
|
|
50
53
|
}
|
package/bin/commands/typings.js
CHANGED
|
@@ -10,20 +10,23 @@ export async function typings (entry) {
|
|
|
10
10
|
if (!npmExists) {
|
|
11
11
|
console.error('npm not found')
|
|
12
12
|
console.error('is node installed?')
|
|
13
|
-
process.
|
|
13
|
+
process.exitCode = 1
|
|
14
|
+
return
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
const esbuildExists = await installed('typescript')
|
|
17
18
|
if (!esbuildExists) {
|
|
18
19
|
console.error('typescript not found')
|
|
19
20
|
console.error('typescript can be installed with `npm i -g typescript`')
|
|
20
|
-
process.
|
|
21
|
+
process.exitCode = 1
|
|
22
|
+
return
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
spawn('tsc', [entry, '-t', 'esnext', '--allowJS', '--checkJS', '--skipLibCheck', '--declaration', '--emitDeclarationOnly', '--noEmitOnError'], {
|
|
24
26
|
cwd: process.cwd(),
|
|
25
27
|
stdio: ['pipe', process.stdout, process.stderr]
|
|
26
|
-
}).on('error',
|
|
27
|
-
console.error(
|
|
28
|
+
}).on('error', error => {
|
|
29
|
+
console.error(error)
|
|
30
|
+
process.exitCode = 1
|
|
28
31
|
})
|
|
29
32
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vanillaes/esmtk",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "ES Module Toolkit",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ecmascript",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@vanillaes/lint-es": "^1.0.0",
|
|
57
|
-
"@vanillaes/tape-es": "^4.0.
|
|
57
|
+
"@vanillaes/tape-es": "^4.0.5",
|
|
58
58
|
"commander": "^14.0.3"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
package/src/cp.js
CHANGED
|
@@ -12,16 +12,19 @@ export async function copyAsync (source, target, force = false) {
|
|
|
12
12
|
const sExists = await fileExists(source)
|
|
13
13
|
if (!sExists) {
|
|
14
14
|
console.error(`cp: ${source} No such file or directory`)
|
|
15
|
-
process.
|
|
15
|
+
process.exitCode = 1
|
|
16
|
+
return
|
|
16
17
|
}
|
|
17
18
|
const sStats = await stat(source)
|
|
18
19
|
if (sStats.isSymbolicLink()) {
|
|
19
20
|
console.error(`cp: ${source} is a sybolic link (not copied)`)
|
|
20
|
-
process.
|
|
21
|
+
process.exitCode = 1
|
|
22
|
+
return
|
|
21
23
|
}
|
|
22
24
|
if (!sStats.isFile()) {
|
|
23
25
|
console.error(`cp: ${source} is a directory (not copied)`)
|
|
24
|
-
process.
|
|
26
|
+
process.exitCode = 1
|
|
27
|
+
return
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
const tExists = await fileExists(target)
|
|
@@ -30,12 +33,14 @@ export async function copyAsync (source, target, force = false) {
|
|
|
30
33
|
if (tIsDir) {
|
|
31
34
|
if (!tExists) {
|
|
32
35
|
console.error(`cp: ${target} No such file or directory`)
|
|
33
|
-
process.
|
|
36
|
+
process.exitCode = 1
|
|
37
|
+
return
|
|
34
38
|
}
|
|
35
39
|
const tStats = await stat(target)
|
|
36
40
|
if (tStats.isSymbolicLink()) {
|
|
37
41
|
console.error(`cp: ${target} is a sybolic link (not copied)`)
|
|
38
|
-
process.
|
|
42
|
+
process.exitCode = 1
|
|
43
|
+
return
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
// append source file name to target directory
|
|
@@ -46,8 +51,9 @@ export async function copyAsync (source, target, force = false) {
|
|
|
46
51
|
|
|
47
52
|
try {
|
|
48
53
|
await cp(source, target, { force: true })
|
|
49
|
-
} catch (
|
|
50
|
-
console.error(`cp: error ${
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error(`cp: error ${error.message}`)
|
|
56
|
+
process.exitCode = 1
|
|
51
57
|
}
|
|
52
58
|
}
|
|
53
59
|
|
|
@@ -61,12 +67,14 @@ export async function copyMultipleAsync (sources, target, force = false) {
|
|
|
61
67
|
const tExists = await fileExists(target)
|
|
62
68
|
if (!tExists) {
|
|
63
69
|
console.error(`cp: ${target} No such file or directory`)
|
|
64
|
-
process.
|
|
70
|
+
process.exitCode = 1
|
|
71
|
+
return
|
|
65
72
|
}
|
|
66
73
|
const tStats = await stat(target)
|
|
67
74
|
if (tStats.isSymbolicLink()) {
|
|
68
75
|
console.error(`cp: ${target} is a sybolic link (not copied)`)
|
|
69
|
-
process.
|
|
76
|
+
process.exitCode = 1
|
|
77
|
+
return
|
|
70
78
|
}
|
|
71
79
|
|
|
72
80
|
try {
|
|
@@ -74,8 +82,9 @@ export async function copyMultipleAsync (sources, target, force = false) {
|
|
|
74
82
|
for (const source of sources) {
|
|
75
83
|
await cp(source, `${target}${sep}${basename(source)}`, { force: true })
|
|
76
84
|
}
|
|
77
|
-
} catch (
|
|
78
|
-
console.error(`cp": error ${
|
|
85
|
+
} catch (error) {
|
|
86
|
+
console.error(`cp": error ${error.message}`)
|
|
87
|
+
process.exitCode = 1
|
|
79
88
|
}
|
|
80
89
|
}
|
|
81
90
|
|
|
@@ -89,32 +98,38 @@ export async function copyRecursiveAsync (source, target, force = false) {
|
|
|
89
98
|
const sExists = await fileExists(source)
|
|
90
99
|
if (!sExists) {
|
|
91
100
|
console.error(`cp: ${source} No such file or directory`)
|
|
92
|
-
process.
|
|
101
|
+
process.exitCode = 1
|
|
102
|
+
return
|
|
93
103
|
}
|
|
94
104
|
const sStats = await stat(source)
|
|
95
105
|
if (sStats.isSymbolicLink()) {
|
|
96
106
|
console.error(`cp: ${source} is a sybolic link (not copied)`)
|
|
97
|
-
process.
|
|
107
|
+
process.exitCode = 1
|
|
108
|
+
return
|
|
98
109
|
}
|
|
99
110
|
|
|
100
111
|
const tExists = await fileExists(target)
|
|
101
112
|
if (!tExists) {
|
|
102
113
|
console.error(`cp: ${target} No such file or directory`)
|
|
103
|
-
process.
|
|
114
|
+
process.exitCode = 1
|
|
115
|
+
return
|
|
104
116
|
}
|
|
105
117
|
const tStats = await stat(target)
|
|
106
118
|
if (tStats.isSymbolicLink()) {
|
|
107
119
|
console.error(`cp: ${target} is a sybolic link (not copied)`)
|
|
108
|
-
process.
|
|
120
|
+
process.exitCode = 1
|
|
121
|
+
return
|
|
109
122
|
}
|
|
110
123
|
if (!tStats.isDirectory()) {
|
|
111
124
|
console.error(`cp: target ${target} Not a directory`)
|
|
112
|
-
process.
|
|
125
|
+
process.exitCode = 1
|
|
126
|
+
return
|
|
113
127
|
}
|
|
114
128
|
|
|
115
129
|
try {
|
|
116
130
|
await cp(source, target, { force: true, recursive: true })
|
|
117
|
-
} catch (
|
|
118
|
-
console.error(`cp": error ${
|
|
131
|
+
} catch (error) {
|
|
132
|
+
console.error(`cp": error ${error.message}`)
|
|
133
|
+
process.exitCode = 1
|
|
119
134
|
}
|
|
120
135
|
}
|
package/src/rm.js
CHANGED
|
@@ -10,22 +10,25 @@ export async function removeAsync (path, force = false) {
|
|
|
10
10
|
const exists = await fileExists(path)
|
|
11
11
|
if (!exists) {
|
|
12
12
|
console.error(`rm: ${path} No such file or directory`)
|
|
13
|
-
process.
|
|
13
|
+
process.exitCode = 1
|
|
14
|
+
return
|
|
14
15
|
}
|
|
15
16
|
const stats = await stat(path)
|
|
16
17
|
if (stats.isSymbolicLink()) {
|
|
17
18
|
console.error(`rm: ${path} is a sybolic link`)
|
|
18
|
-
process.
|
|
19
|
+
process.exitCode = 1
|
|
20
|
+
return
|
|
19
21
|
}
|
|
20
22
|
if (!stats.isFile()) {
|
|
21
23
|
console.error(`rm: ${path} is a directory`)
|
|
22
|
-
process.
|
|
24
|
+
process.exitCode = 1
|
|
25
|
+
return
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
try {
|
|
26
29
|
await rm(path, { force: true })
|
|
27
|
-
} catch (
|
|
28
|
-
console.error(`rm: error ${
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error(`rm: error ${error.message}`)
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
|
|
@@ -39,8 +42,8 @@ export async function removeMultipleAsync (files, force = false) {
|
|
|
39
42
|
for (const file of files) {
|
|
40
43
|
await rm(file, { force: true })
|
|
41
44
|
}
|
|
42
|
-
} catch (
|
|
43
|
-
console.error(`cp": error ${
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error(`cp": error ${error.message}`)
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
49
|
|
|
@@ -53,17 +56,19 @@ export async function removeRecursiveAsync (path, force = false) {
|
|
|
53
56
|
const exists = await fileExists(path)
|
|
54
57
|
if (!exists) {
|
|
55
58
|
console.error(`rm: ${path} No such file or directory`)
|
|
56
|
-
process.
|
|
59
|
+
process.exitCode = 1
|
|
60
|
+
return
|
|
57
61
|
}
|
|
58
62
|
const stats = await stat(path)
|
|
59
63
|
if (stats.isSymbolicLink()) {
|
|
60
64
|
console.error(`rm: ${path} is a sybolic link`)
|
|
61
|
-
process.
|
|
65
|
+
process.exitCode = 1
|
|
66
|
+
return
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
try {
|
|
65
70
|
await rm(path, { force: true, recursive: true })
|
|
66
|
-
} catch (
|
|
67
|
-
console.error(`rm": error ${
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.error(`rm": error ${error.message}`)
|
|
68
73
|
}
|
|
69
74
|
}
|
package/src/util.js
CHANGED
|
@@ -15,14 +15,16 @@ export async function expand (source) {
|
|
|
15
15
|
const paths = await match(source)
|
|
16
16
|
if (paths.length === 0) {
|
|
17
17
|
console.error(`${source} no matches found`)
|
|
18
|
-
process.
|
|
18
|
+
process.exitCode = 1
|
|
19
|
+
return
|
|
19
20
|
}
|
|
20
21
|
return paths
|
|
21
22
|
} else {
|
|
22
23
|
const exists = await fileExists(source)
|
|
23
24
|
if (!exists) {
|
|
24
25
|
console.error(`${source} No such file or directory`)
|
|
25
|
-
process.
|
|
26
|
+
process.exitCode = 1
|
|
27
|
+
return
|
|
26
28
|
}
|
|
27
29
|
return [source]
|
|
28
30
|
}
|
|
@@ -51,7 +53,7 @@ export async function installed (pkg) {
|
|
|
51
53
|
try {
|
|
52
54
|
await execAsync(`npm list -g --depth=0 ${pkg}`)
|
|
53
55
|
return true
|
|
54
|
-
} catch (
|
|
56
|
+
} catch (error) {
|
|
55
57
|
return false
|
|
56
58
|
}
|
|
57
59
|
}
|
|
@@ -80,7 +82,7 @@ export async function which (program) {
|
|
|
80
82
|
try {
|
|
81
83
|
await execAsync(`which ${program}`)
|
|
82
84
|
return true
|
|
83
|
-
} catch (
|
|
85
|
+
} catch (error) {
|
|
84
86
|
return false
|
|
85
87
|
}
|
|
86
88
|
}
|