Last active
December 21, 2015 12:51
-
-
Save jamiebuilds/2778e4df363612635989 to your computer and use it in GitHub Desktop.
Example single-file gulp setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {src, dest, watch, parallel, series} from 'gulp'; | |
import lintPlugin from 'gulp-lint-plugin'; | |
import testPlugin from 'gulp-test-plugin'; | |
import buildPlugin from 'gulp-build-plugin'; | |
const SRC_DIRECTORY = './src'; | |
const TEST_DIRECTORY = './test'; | |
const DIST_DIRECTORY = './dist'; | |
const lintDir = dir => src(dir) | |
.pipe(lintPlugin()); | |
const lintSrc = () => lintDir(SRC_DIRECTORY); | |
const lintTest = () => lintDir(TEST_DIRECTORY); | |
const lintFiles = parallel(lintSrc, lintTest); | |
const testFiles = () => src(TEST_DIRECTORY) | |
.pipe(testPlugin()); | |
const reportLint = () => lintPlugin.report(); | |
const reportTest = () => testPlugin.report(); | |
const reportLintAndTest = series(reportLint, reportTest); | |
const buildFiles = () => src(SRC_DIRECTORY) | |
.pipe(buildPlugin()) | |
.pipe(dest(DIST_DIRECTORY)); | |
export const lint = series(lintFiles, reportLint); | |
export const test = series(parallel(lint, testFiles), reportLintAnTest); | |
export const build = series(test, buildFiles); | |
export const dev = () => { | |
watch(SRC_DIRECTORY, parallel(test, build)); | |
watch(TEST_DIRECTORY, test); | |
}; | |
export default dev; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment