Skip to content

Commit d32e274

Browse files
committed
Fix Gulp
1 parent 37695ef commit d32e274

File tree

8 files changed

+53
-558
lines changed

8 files changed

+53
-558
lines changed

gulp/files.json

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
{
2-
"JAVASCRIPT": [
2+
"CHECK": [
33
"{index,custom,gulpfile}.js",
4-
"src/*.js",
5-
"src/**/*.js",
6-
"gulp/*.js",
7-
"gulp/**/*.js",
8-
"test/*.js",
9-
"test/**/*.js",
10-
"examples/*.js",
11-
"examples/**/*.js"
4+
"{src,gulp,test,examples}/*.js",
5+
"{src,gulp,test,examples}/**/*.js",
6+
"*.md"
127
],
13-
"TRANSPILED": ["src", "test", "helpers"],
14-
"MARKDOWN": ["*.md"]
8+
"UNIT": ["{index,custom}.js", "src", "test"],
9+
"TEST": [
10+
"{index,custom,gulpfile}.js",
11+
"src",
12+
"gulp",
13+
"test",
14+
"examples",
15+
"*.md"
16+
],
17+
"BUILD": ["src", "test", "helpers"],
18+
"DEV": [
19+
"{index,custom,gulpfile}.js",
20+
"src",
21+
"gulp",
22+
"test",
23+
"helpers",
24+
"examples",
25+
"*.md"
26+
]
1527
}

gulp/tasks/build.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
const { series } = require('gulp')
44

55
const { getWatchTask } = require('../utils')
6-
const { TRANSPILED } = require('../files')
6+
const FILES = require('../files')
77
const gulpExeca = require('../exec')
88

99
const babel = function() {
10-
const promises = TRANSPILED.map(dir =>
10+
const promises = FILES.BUILD.map(dir =>
1111
gulpExeca(
1212
`babel ${dir} --out-dir dist/${dir} --copy-files --delete-dir-on-start --source-maps --no-comments --minified --retain-lines`,
1313
),
@@ -20,7 +20,7 @@ const build = series(babel)
2020
// eslint-disable-next-line fp/no-mutation
2121
build.description = 'Build source files'
2222

23-
const buildwatch = getWatchTask({ TRANSPILED: build }, build)
23+
const buildwatch = getWatchTask({ BUILD: build }, build)
2424

2525
// eslint-disable-next-line fp/no-mutation
2626
buildwatch.description = 'Build source files in watch mode'

gulp/tasks/check.js

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,24 @@ const FILES = require('../files')
77
const { getWatchTask } = require('../utils')
88
const gulpExeca = require('../exec')
99

10-
const format = function() {
11-
const files = [...FILES.JAVASCRIPT].join(' ')
12-
return gulpExeca(`prettier --write --loglevel warn ${files}`)
13-
}
10+
const format = () =>
11+
gulpExeca(`prettier --write --loglevel warn ${FILES.CHECK.join(' ')}`)
1412

1513
// We do not use `gulp-eslint` because it does not support --cache
16-
const eslint = function() {
17-
const files = [...FILES.JAVASCRIPT, ...FILES.MARKDOWN].join(' ')
18-
return gulpExeca(
19-
`eslint ${files} --ignore-path .gitignore --fix --cache --format codeframe --max-warnings 0 --report-unused-disable-directives`,
14+
const eslint = () =>
15+
gulpExeca(
16+
`eslint ${FILES.CHECK.join(
17+
' ',
18+
)} --ignore-path .gitignore --fix --cache --format codeframe --max-warnings 0 --report-unused-disable-directives`,
2019
)
21-
}
2220

2321
const lint = series(format, eslint)
2422

2523
// eslint-disable-next-line fp/no-mutation
2624
lint.description = 'Lint source files'
2725

28-
const dup = function() {
29-
return src([...FILES.JAVASCRIPT, ...FILES.MARKDOWN]).pipe(
26+
const dup = () =>
27+
src(FILES.CHECK).pipe(
3028
jscpd({
3129
verbose: true,
3230
blame: true,
@@ -35,7 +33,6 @@ const dup = function() {
3533
'skip-comments': true,
3634
}),
3735
)
38-
}
3936

4037
// eslint-disable-next-line fp/no-mutation
4138
dup.description = 'Check for code duplication'
@@ -45,10 +42,7 @@ const check = parallel(lint, dup)
4542
// eslint-disable-next-line fp/no-mutation
4643
check.description = 'Lint and check for code duplication'
4744

48-
const checkwatch = getWatchTask(
49-
{ JAVASCRIPT: [lint, dup], MARKDOWN: [lint, dup] },
50-
check,
51-
)
45+
const checkwatch = getWatchTask({ CHECK: check }, check)
5246

5347
// eslint-disable-next-line fp/no-mutation
5448
checkwatch.description = 'Lint and test the application in watch mode'

gulp/tasks/main.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
'use strict'
22

3-
const { parallel } = require('gulp')
3+
const { series } = require('gulp')
44

5-
const { testwatch } = require('./test')
6-
const { buildwatch } = require('./build')
5+
const { getWatchTask } = require('../utils')
76

8-
const dev = parallel(testwatch, buildwatch)
7+
const { test } = require('./test')
8+
const { build } = require('./build')
9+
10+
const devTask = series(build, test)
11+
12+
const dev = getWatchTask({ DEV: devTask }, devTask)
913

1014
// eslint-disable-next-line fp/no-mutation
1115
dev.description = 'Lint, test and build source files'

gulp/tasks/test.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
'use strict'
22

3-
const { series, parallel } = require('gulp')
3+
const { series } = require('gulp')
44

5-
const { check, checkwatch } = require('./check')
6-
const { unit, unitwatch } = require('./unit')
5+
const { getWatchTask } = require('../utils')
6+
7+
const { check } = require('./check')
8+
const { unit } = require('./unit')
79

810
const testTask = series(check, unit)
911

1012
// eslint-disable-next-line fp/no-mutation
1113
testTask.description = 'Lint and test source files'
1214

13-
const testwatch = parallel(checkwatch, unitwatch)
15+
const testwatch = getWatchTask({ TEST: testTask }, testTask)
1416

1517
// eslint-disable-next-line fp/no-mutation
1618
testwatch.description = 'Lint and test source files in watch mode'

gulp/tasks/unit.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const { promisify } = require('util')
55

66
const { load: loadYaml } = require('js-yaml')
77

8+
const { getWatchTask } = require('../utils')
89
const gulpExeca = require('../exec')
910

1011
const TRAVIS_CONFIG = `${__dirname}/../../.travis.yml`
@@ -15,7 +16,7 @@ const unit = () => gulpExeca('ava')
1516
unit.description = 'Run unit tests'
1617

1718
// We have to use this to debug Ava test files with Chrome devtools
18-
const unitwatch = () => gulpExeca('ndb ava -w')
19+
const unitwatch = getWatchTask({ UNIT: unit }, unit)
1920

2021
// eslint-disable-next-line fp/no-mutation
2122
unitwatch.description = 'Run unit tests in watch mode'
@@ -43,7 +44,7 @@ const getNodeVersions = async function() {
4344
const NVM_PATH = '~/.nvm/nvm.sh'
4445

4546
// eslint-disable-next-line fp/no-mutation
46-
unit.description = 'Run unit tests on all supported Node.js versions'
47+
unitfull.description = 'Run unit tests on all supported Node.js versions'
4748

4849
module.exports = {
4950
unit,

0 commit comments

Comments
 (0)