Created
November 23, 2015 22:20
-
-
Save brandonpapworth/7082326f9c1028e2bce5 to your computer and use it in GitHub Desktop.
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
'use strict'; | |
const path = require('path'); | |
const del = require('del'); | |
const gulp = require('gulp'); | |
const watch = require('gulp-watch'); | |
const FILE_SRC_GLOB = ['src/**/*']; | |
const FILE_SRC_GLOB_NO_JS = [FILE_SRC_GLOB[0], `!${FILE_SRC_GLOB[0]}.js`]; | |
const FILE_DEST_GLOB = 'app'; | |
const JS_SRC_GLOB = [`${FILE_SRC_GLOB[0]}.js`]; | |
const JS_DEST_DIR = FILE_DEST_GLOB; | |
function destPathFromSrc(srcGlob, destGlob, srcPath) { | |
return path.resolve(destGlob, path.relative(path.resolve(srcGlob), srcPath)); | |
} | |
gulp.task('watch:sync-deletes', () => { | |
return new Promise((resolve, reject) => { | |
watch(FILE_SRC_GLOB, {name: 'watch:sync-deletes', ignoreInitial: true, events: ['unlink'], read: false}, vinylFile => { | |
let destPath = destPathFromSrc('src', FILE_DEST_GLOB, vinylFile.path); | |
del(destPath); | |
// Handle removal of sourcemaps | |
if (path.extname(vinylFile.path) == '.js') { | |
del(destPath + '.map'); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment