@jcoreio/toolchain 1.0.0-beta.9 → 1.0.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcoreio/toolchain",
3
- "version": "1.0.0-beta.9",
3
+ "version": "1.0.0",
4
4
  "description": "base JS build toolchain",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,6 +13,8 @@ async function bootstrapProjectPackageJson() {
13
13
  const devDependencies =
14
14
  packageJson.devDependencies || (packageJson.devDependencies = {})
15
15
 
16
+ await getPluginsAsyncFunction('bootstrapProjectPackageJson')(packageJson)
17
+
16
18
  for (const path of [
17
19
  'commitlint',
18
20
  'config.commitizen',
@@ -105,8 +107,6 @@ async function bootstrapProjectPackageJson() {
105
107
  }
106
108
  }
107
109
 
108
- await getPluginsAsyncFunction('bootstrapProjectPackageJson')(packageJson)
109
-
110
110
  sortDeps(packageJson)
111
111
 
112
112
  await fs.writeJson('package.json', packageJson, { spaces: 2 })
@@ -13,6 +13,7 @@ module.exports = [
13
13
  'commitlint.config.js',
14
14
  '.eslintignore',
15
15
  '.gitignore',
16
+ 'husky.config.js',
16
17
  '.lintstagedrc',
17
18
  'lint-staged.config.js',
18
19
  '.npmignore',
@@ -1,9 +1,9 @@
1
1
  const check = require('./check.cjs')
2
2
  const build = require('./build.cjs')
3
- const scripts = require('./toolchain.cjs')
4
3
 
5
4
  exports.run = async function (args = []) {
6
5
  await check.run()
6
+ const { scripts } = require('./toolchain.cjs')
7
7
  if (scripts.coverage) await scripts.coverage.run()
8
8
  await build.run()
9
9
  }
package/util/execa.cjs CHANGED
@@ -14,7 +14,7 @@ function extractCommand(command) {
14
14
  return match ? match[0] : command
15
15
  }
16
16
 
17
- module.exports = async function defaultExeca(command, args, options, ...rest) {
17
+ function getExecaArgs(command, args, options, ...rest) {
18
18
  if (args instanceof Object && !Array.isArray(args)) {
19
19
  options = args
20
20
  args = []
@@ -46,27 +46,53 @@ module.exports = async function defaultExeca(command, args, options, ...rest) {
46
46
  },
47
47
  }
48
48
 
49
- const child = execa(command, args, opts, ...rest)
50
- child.then(
49
+ return [command, args, opts, ...rest]
50
+ }
51
+
52
+ function convertExecaError(command, error) {
53
+ const { code, signal } = error
54
+ if (code) {
55
+ error.message = chalk`{red ✖} {bold ${extractCommand(
56
+ command
57
+ )}} exited with code ${code}`
58
+ }
59
+ if (signal) {
60
+ error.message = chalk`{red ✖} {bold ${extractCommand(
61
+ command
62
+ )}} was killed with signal ${signal}`
63
+ }
64
+ return error
65
+ }
66
+
67
+ function logSuccess(command) {
68
+ // eslint-disable-next-line no-console
69
+ console.error(
70
+ chalk`{green ✔} {bold ${extractCommand(command)}} exited with code 0`
71
+ )
72
+ }
73
+
74
+ function defaultExeca(command, args, options, ...rest) {
75
+ return execa(...getExecaArgs(command, args, options, ...rest)).then(
51
76
  (result) => {
52
- // eslint-disable-next-line no-console
53
- console.error(
54
- chalk`{green ✔} {bold ${extractCommand(command)}} exited with code 0`
55
- )
77
+ logSuccess(command)
78
+ return result
56
79
  },
57
80
  (error) => {
58
- const { code, signal } = error
59
- if (code) {
60
- error.message = chalk`{red ✖} {bold ${extractCommand(
61
- command
62
- )}} exited with code ${code}`
63
- }
64
- if (signal) {
65
- error.message = chalk`{red ✖} {bold ${extractCommand(
66
- command
67
- )}} was killed with signal ${signal}`
68
- }
81
+ throw convertExecaError(command, error)
69
82
  }
70
83
  )
71
- return child
72
84
  }
85
+
86
+ function defaultExecaSync(command, args, options, ...rest) {
87
+ try {
88
+ const result = execa.sync(...getExecaArgs(command, args, options, ...rest))
89
+ logSuccess(command)
90
+ return result
91
+ } catch (error) {
92
+ throw convertExecaError(command, error)
93
+ }
94
+ }
95
+
96
+ defaultExeca.sync = defaultExecaSync
97
+
98
+ module.exports = defaultExeca