Skip to content

Instantly share code, notes, and snippets.

@jamiebuilds
Last active December 21, 2015 12:51
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiebuilds/2778e4df363612635989 to your computer and use it in GitHub Desktop.
Save jamiebuilds/2778e4df363612635989 to your computer and use it in GitHub Desktop.
Example single-file gulp setup
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