update watch task

This commit is contained in:
Tim Lancina
2015-12-10 16:37:15 -06:00
parent 36a2349674
commit b72889f002

View File

@ -70,18 +70,7 @@ gulp.task('watch', function(done) {
], ],
function(file) { function(file) {
if (file.event === "unlink") { if (file.event === "unlink") {
var basePath = file.base.substring(0, file.base.lastIndexOf("ionic/")); deleteFile(file);
var relPath = file.history[0].replace(basePath, "").replace(".ts", ".js");
var es6Path = basePath + "dist/src/es6/" + relPath;
var commonPath = basePath + "dist/src/es5/common/" + relPath;
var systemPath = basePath + "dist/src/es5/system/" + relPath;
delete cache.caches.transpile[file.history[0]];
del([es6Path, commonPath, systemPath], function(){
gulp.start('bundle');
});
} else { } else {
gulp.start('bundle'); gulp.start('bundle');
} }
@ -89,21 +78,7 @@ gulp.task('watch', function(done) {
); );
watch('ionic/components/*/test/**/*', function(file) { watch('ionic/components/*/test/**/*', function(file) {
if (file.event === "unlink") { gulp.start('e2e');
var paths = file.history[0].split("ionic/components/");
var basePath = paths[0],
relPath = paths[1].split("/test").join("").replace(".ts", ".js");
var distPath = basePath + "dist/e2e/" + relPath;
delete cache.caches.e2e[file.history[0]];
del([distPath], function(){
gulp.start('e2e');
});
} else {
gulp.start('e2e');
}
}); });
watch('ionic/**/*.scss', function() { watch('ionic/**/*.scss', function() {
@ -113,6 +88,20 @@ gulp.task('watch', function(done) {
done(); done();
} }
); );
function deleteFile(file) {
var basePath = file.base.substring(0, file.base.lastIndexOf("ionic/"));
var relativePath = file.history[0].replace(file.base, '').replace('.ts', '.js');
var filePath = basePath + 'dist/' + relativePath;
var typingPath = filePath.replace('.js', '.d.ts');
delete cache.caches.transpile[file.history[0]];
del([filePath, typingPath], function(){
gulp.start('bundle');
});
}
}); });
gulp.task('serve', function() { gulp.task('serve', function() {