@jcoreio/toolchain-mocha 4.7.0 → 4.9.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 +2 -2
- package/plugins/getConfigFiles.cjs +39 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jcoreio/toolchain-mocha",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.9.0",
|
|
4
4
|
"description": "Mocha build toolchain",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"nyc": "^15.1.0",
|
|
27
27
|
"resolve-bin": "^1.0.0",
|
|
28
28
|
"semver": "^7.5.3",
|
|
29
|
-
"@jcoreio/toolchain": "4.
|
|
29
|
+
"@jcoreio/toolchain": "4.9.0"
|
|
30
30
|
},
|
|
31
31
|
"toolchainManaged": {
|
|
32
32
|
"devDependencies": {
|
|
@@ -1,23 +1,51 @@
|
|
|
1
1
|
const { name } = require('../package.json')
|
|
2
2
|
const dedent = require('dedent-js')
|
|
3
|
+
const { globExists } = require('@jcoreio/toolchain/util/glob.cjs')
|
|
4
|
+
const getPluginsArraySync = require('@jcoreio/toolchain/util/getPluginsArraySync.cjs')
|
|
3
5
|
|
|
4
6
|
module.exports = [
|
|
5
7
|
async function getConfigFiles({ fromVersion }) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
for (const file of ['.mocharc.cjs', 'nyc.config.cjs']) {
|
|
9
|
-
files[file] = async (existing) =>
|
|
8
|
+
return {
|
|
9
|
+
'nyc.config.cjs': async (existing) =>
|
|
10
10
|
existing && fromVersion
|
|
11
11
|
? existing
|
|
12
12
|
: dedent`
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
/* eslint-env node, es2018 */
|
|
14
|
+
const base = require('${name}/nyc.config.cjs')
|
|
15
|
+
module.exports = {
|
|
16
|
+
...base,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
`,
|
|
20
|
+
'.mocharc.cjs': async (existing) => {
|
|
21
|
+
if (existing && fromVersion) return existing
|
|
22
|
+
const specs = []
|
|
23
|
+
if (await globExists('test')) {
|
|
24
|
+
specs.push('test')
|
|
25
|
+
}
|
|
26
|
+
if (await globExists('src/**/__tests__')) {
|
|
27
|
+
specs.push('src/**/__tests__')
|
|
28
|
+
}
|
|
29
|
+
const specFilePattern = `src/**/*.{test,spec}.{${getPluginsArraySync(
|
|
30
|
+
'sourceExtensions'
|
|
31
|
+
).join(',')}}`
|
|
32
|
+
if (
|
|
33
|
+
await globExists(specFilePattern, { ignore: 'src/**/__tests__/**' })
|
|
34
|
+
) {
|
|
35
|
+
specs.push(specFilePattern)
|
|
17
36
|
}
|
|
18
|
-
|
|
19
|
-
|
|
37
|
+
if (!specs.length) specs.push('test')
|
|
38
|
+
return dedent`
|
|
39
|
+
/* eslint-env node, es2018 */
|
|
40
|
+
const base = require('${name}/.mocharc.cjs')
|
|
41
|
+
const { getSpecs } = require('${name}')
|
|
42
|
+
module.exports = {
|
|
43
|
+
...base,
|
|
44
|
+
spec: getSpecs(${JSON.stringify(specs, null, 2)}),
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
`
|
|
48
|
+
},
|
|
20
49
|
}
|
|
21
|
-
return files
|
|
22
50
|
},
|
|
23
51
|
]
|