@vanillaes/esmtk 1.5.0 → 1.5.1

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.
@@ -33,11 +33,20 @@ export async function bundle (input, output, options) {
33
33
  args.push(input)
34
34
  args.push(`--outfile=${output}`)
35
35
 
36
- spawn('esbuild', args, {
36
+ const child = spawn('esbuild', args, {
37
37
  cwd: process.cwd(),
38
38
  stdio: ['pipe', process.stdout, process.stderr]
39
- }).on('error', error => {
39
+ })
40
+
41
+ child.on('error', error => {
40
42
  console.error(error)
41
43
  process.exitCode = 1
42
44
  })
45
+
46
+ // forward the error code
47
+ child.on('close', (/** @type {number} */ code) => {
48
+ if (code === 1) {
49
+ process.exitCode = 1
50
+ }
51
+ })
43
52
  }
@@ -15,30 +15,30 @@ export async function clean (cwd, options) {
15
15
  }
16
16
 
17
17
  if (options?.bundle) {
18
- await cleanOne(cwd, options.bundle, options)
18
+ await cleanCategory(cwd, options.bundle, options)
19
19
  }
20
20
 
21
21
  if (options?.minify) {
22
- await cleanOne(cwd, options.minify, options)
22
+ await cleanCategory(cwd, options.minify, options)
23
23
  }
24
24
 
25
25
  if (options?.typings) {
26
- await cleanOne(cwd, options.typings, options)
26
+ await cleanCategory(cwd, options.typings, options)
27
27
  }
28
28
 
29
29
  if (options?.custom) {
30
- await cleanOne(cwd, options.custom, options)
30
+ await cleanCategory(cwd, options.custom, options)
31
31
  }
32
32
  }
33
33
 
34
34
  /**
35
- * Run one category of build artifacts
35
+ * Clean one category of build artifacts
36
36
  * @private
37
37
  * @param {string} cwd the current working directory (default process.cwd())
38
38
  * @param {string} glob the pattern of files to match
39
39
  * @param {object} options 'clean' options
40
40
  */
41
- async function cleanOne (cwd, glob, options) {
41
+ async function cleanCategory (cwd, glob, options) {
42
42
  const files = await match(glob, cwd, 'node_modules/**')
43
43
  await removeMultipleAsync(files, options?.force)
44
44
  }
@@ -33,11 +33,20 @@ export async function commonjs (input, output, options) {
33
33
  args.push(input)
34
34
  args.push(`--outfile=${output}`)
35
35
 
36
- spawn('esbuild', args, {
36
+ const child = spawn('esbuild', args, {
37
37
  cwd: process.cwd(),
38
38
  stdio: ['pipe', process.stdout, process.stderr]
39
- }).on('error', error => {
39
+ })
40
+
41
+ child.on('error', error => {
40
42
  console.error(error)
41
43
  process.exitCode = 1
42
44
  })
45
+
46
+ // forward the error code
47
+ child.on('close', (/** @type {number} */ code) => {
48
+ if (code === 1) {
49
+ process.exitCode = 1
50
+ }
51
+ })
43
52
  }
@@ -16,9 +16,6 @@ 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', error => {
20
- console.error(`${error}`)
21
- process.exitCode = 1
22
19
  })
23
20
 
24
21
  child.stdout.on('data', (data) => {
@@ -26,11 +23,31 @@ export async function lint (options) {
26
23
  })
27
24
 
28
25
  child.stderr.on('data', (data) => {
29
- if (data.toString() === 'lint-es: Run `lint-es --fix` to automatically fix some problems.\n') {
26
+ data = data.toString()
27
+ // VSCode debug dumps to stderr for some reason, ignore it
28
+ if (data === 'Debugger attached.\n' || data === 'Waiting for the debugger to disconnect...\n') {
29
+ return
30
+ }
31
+
32
+ // catch the --fix message and rewrite it
33
+ if (data.startsWith('lint-es: Run `lint-es --fix` to automatically fix some problems.\n')) {
30
34
  process.stderr.write('esmtk: Run `esmtk lint --fix` to automatically fix some problems.\n')
35
+ return
31
36
  } else {
32
- process.stderr.write(`${data}`)
37
+ process.stderr.write(data)
33
38
  }
34
39
  process.exitCode = 1
35
40
  })
41
+
42
+ child.on('error', error => {
43
+ console.error(`${error}`)
44
+ process.exitCode = 1
45
+ })
46
+
47
+ // forward the error code
48
+ child.on('close', (/** @type {number} */ code) => {
49
+ if (code === 1) {
50
+ process.exitCode = 1
51
+ }
52
+ })
36
53
  }
@@ -37,11 +37,20 @@ export async function minify (input, output, options) {
37
37
  args.push(input)
38
38
  args.push(`--outfile=${output}`)
39
39
 
40
- spawn('esbuild', args, {
40
+ const child = spawn('esbuild', args, {
41
41
  cwd: process.cwd(),
42
42
  stdio: ['pipe', process.stdout, process.stderr]
43
- }).on('error', error => {
43
+ })
44
+
45
+ child.on('error', error => {
44
46
  console.error(error)
45
47
  process.exitCode = 1
46
48
  })
49
+
50
+ // forward the error code
51
+ child.on('close', (/** @type {number} */ code) => {
52
+ if (code === 1) {
53
+ process.exitCode = 1
54
+ }
55
+ })
47
56
  }
@@ -24,9 +24,6 @@ export async function test (glob, options) {
24
24
  const child = spawn('node', args, {
25
25
  cwd: process.cwd(),
26
26
  stdio: ['pipe', 'pipe', 'pipe']
27
- }).on('error', error => {
28
- console.error(error)
29
- process.exitCode = 1
30
27
  })
31
28
 
32
29
  child.stdout.on('data', (data) => {
@@ -34,7 +31,23 @@ export async function test (glob, options) {
34
31
  })
35
32
 
36
33
  child.stderr.on('data', (data) => {
37
- process.stderr.write(`${data}`)
34
+ data = data.toString()
35
+ if (data === 'Debugger attached.\n' || data === 'Waiting for the debugger to disconnect...\n') {
36
+ return
37
+ }
38
+ process.stderr.write(data)
39
+ process.exitCode = 1
40
+ })
41
+
42
+ child.on('error', error => {
43
+ console.error(error)
38
44
  process.exitCode = 1
39
45
  })
46
+
47
+ // forward the error code
48
+ child.on('close', (/** @type {number} */ code) => {
49
+ if (code === 1) {
50
+ process.exitCode = 1
51
+ }
52
+ })
40
53
  }
@@ -43,11 +43,20 @@ export async function type (entry, options) {
43
43
  args.push(options.types)
44
44
  }
45
45
 
46
- spawn('tsc', args, {
46
+ const child = spawn('tsc', args, {
47
47
  cwd: process.cwd(),
48
48
  stdio: ['pipe', process.stdout, process.stderr]
49
- }).on('error', error => {
49
+ })
50
+
51
+ child.on('error', error => {
50
52
  console.error(error)
51
53
  process.exitCode = 1
52
54
  })
55
+
56
+ // forward the error code
57
+ child.on('close', (/** @type {number} */ code) => {
58
+ if (code === 1) {
59
+ process.exitCode = 1
60
+ }
61
+ })
53
62
  }
@@ -42,11 +42,20 @@ export async function typings (entry, options) {
42
42
  args.push(options.types)
43
43
  }
44
44
 
45
- spawn('tsc', args, {
45
+ const child = spawn('tsc', args, {
46
46
  cwd: process.cwd(),
47
47
  stdio: ['pipe', process.stdout, process.stderr]
48
- }).on('error', error => {
48
+ })
49
+
50
+ child.on('error', error => {
49
51
  console.error(error)
50
52
  process.exitCode = 1
51
53
  })
54
+
55
+ // forward the error code
56
+ child.on('close', (/** @type {number} */ code) => {
57
+ if (code === 1) {
58
+ process.exitCode = 1
59
+ }
60
+ })
52
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vanillaes/esmtk",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "ES Module Toolkit",
5
5
  "keywords": [
6
6
  "ecmascript",