@jcoreio/toolchain-mocha 1.0.0-beta.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.
package/.mocharc.cjs ADDED
@@ -0,0 +1,10 @@
1
+ const getPluginsArraySync = require('@jcoreio/toolchain/util/getPluginsArraySync.cjs')
2
+
3
+ module.exports = {
4
+ require: [require.resolve('./util/configureMocha.cjs')],
5
+ reporter: 'spec',
6
+ spec: [
7
+ require.resolve('./util/mochaWatchClearConsole.cjs'),
8
+ ...getPluginsArraySync('mochaSpecs'),
9
+ ],
10
+ }
package/bin/mocha ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/sh
2
+
3
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
4
+
5
+ exec $(node "$basedir/resolveBin.cjs" mocha) "$@"
package/bin/nyc ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/sh
2
+
3
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
4
+
5
+ exec $(node "$basedir/resolveBin.cjs" nyc) "$@"
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+
3
+ process.stdout.write(
4
+ require('resolve-bin').sync(
5
+ process.argv[2],
6
+ process.argv[3] ? { executable: process.argv[3] } : {}
7
+ )
8
+ )
package/nyc.config.cjs ADDED
@@ -0,0 +1,9 @@
1
+ const getPluginsArraySync = require('@jcoreio/toolchain/util/getPluginsArraySync.cjs')
2
+
3
+ module.exports = {
4
+ include: ['src/**'],
5
+ extension: getPluginsArraySync('sourceExtensions').map((ext) => '.' + ext),
6
+ reporter: ['lcov', 'text'],
7
+ sourceMap: true,
8
+ instrument: true,
9
+ }
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@jcoreio/toolchain-mocha",
3
+ "version": "1.0.0-beta.1",
4
+ "description": "Mocha build toolchain",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/jcoreio/toolchains.git",
8
+ "directory": "packages/mocha"
9
+ },
10
+ "author": "Andy Edwards",
11
+ "license": "MIT",
12
+ "bugs": {
13
+ "url": "https://github.com/jcoreio/toolchains/issues"
14
+ },
15
+ "homepage": "https://github.com/jcoreio/toolchains/tree/beta/packages/mocha",
16
+ "bin": {
17
+ "mocha": "./bin/mocha",
18
+ "nyc": "./bin/nyc"
19
+ },
20
+ "dependencies": {
21
+ "dedent-js": "^1.0.1",
22
+ "mocha": "^9.1.3",
23
+ "nyc": "^15.1.0",
24
+ "resolve-bin": "^1.0.0"
25
+ },
26
+ "peerDependencies": {
27
+ "mocha": "^9.1.3",
28
+ "@jcoreio/toolchain": "1.0.0-beta.1"
29
+ }
30
+ }
@@ -0,0 +1,7 @@
1
+ const execa = require('@jcoreio/toolchain/util/execa.cjs')
2
+
3
+ module.exports = [
4
+ async (args = []) => {
5
+ await execa('nyc', ['mocha', ...args])
6
+ },
7
+ ]
@@ -0,0 +1,19 @@
1
+ const { name } = require('../package.json')
2
+ const dedent = require('dedent-js')
3
+
4
+ module.exports = [
5
+ async function getConfigFiles() {
6
+ const files = {}
7
+ for (const file of ['.mocharc.cjs', 'nyc.config.cjs']) {
8
+ files[file] = dedent`
9
+ /* eslint-env node, es2018 */
10
+ const base = require('${name}/${file}')
11
+ module.exports = {
12
+ ...base,
13
+ }
14
+
15
+ `
16
+ }
17
+ return files
18
+ },
19
+ ]
@@ -0,0 +1,5 @@
1
+ const getPluginsArraySync = require('@jcoreio/toolchain/util/getPluginsArraySync.cjs')
2
+
3
+ module.exports = [
4
+ () => [`test/**/*.{${getPluginsArraySync('sourceExtensions').join(',')}}`],
5
+ ]
@@ -0,0 +1,7 @@
1
+ const execa = require('@jcoreio/toolchain/util/execa.cjs')
2
+
3
+ module.exports = [
4
+ async (args = []) => {
5
+ await execa('mocha', args)
6
+ },
7
+ ]
@@ -0,0 +1,2 @@
1
+ const getPlugins = require('@jcoreio/toolchain/util/getPlugins.cjs')
2
+ for (const plugin of getPlugins('configureMocha')) plugin()
@@ -0,0 +1,5 @@
1
+ const { before } = require('mocha')
2
+
3
+ if (process.argv.indexOf('--watch') >= 0) {
4
+ before(() => process.stdout.write('\u001b[2J\u001b[1;1H\u001b[3J'))
5
+ }