From e1f9fdc2c83d0b15286aeb8f39be34e8612e2ec3 Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Tue, 14 Aug 2018 09:33:19 +0530 Subject: Adds gulp task to remove folders. :lipstick: * Previously most of the temp folder will become a gunk yard if libraries are removed & new one's are added, effect is final archive.zip size is huge because it contains stray files. --- gulpfile.js | 35 +++++++++------ package-lock.json | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 3 files changed, 149 insertions(+), 14 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 0bb7f86..2fc8d42 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,18 +1,20 @@ 'use strict'; -var gulp = require('gulp'); -var browserSync = require('browser-sync'); -var uglify = require('gulp-uglify'); -var zip = require('gulp-vinyl-zip').zip; -var size = require('gulp-size'); -var runSequence = require('run-sequence'); -let rollup = require('rollup-stream'); - -var source = require('vinyl-source-stream'); -var libs = ['./node_modules/kontra/kontra.min.js', './node_modules/tinymusic/dist/TinyMusic.min.js']; -var devLibs = ['./node_modules/jsfxr/jsfxr.js']; -var libFolder = 'libs/'; -var outputTemp = 'temp/'; +const gulp = require('gulp'); +const browserSync = require('browser-sync'); +const uglify = require('gulp-uglify'); +const zip = require('gulp-vinyl-zip').zip; +const size = require('gulp-size'); +const runSequence = require('run-sequence'); +const rollup = require('rollup-stream'); +const del = require('del'); + + +const source = require('vinyl-source-stream'); +const libs = ['./node_modules/kontra/kontra.min.js', './node_modules/tinymusic/dist/TinyMusic.min.js']; +const devLibs = ['./node_modules/jsfxr/jsfxr.js']; +const libFolder = 'libs/'; +const outputTemp = 'temp/'; gulp.task('serve', ['copylibs', 'copylibsDev', 'uglyfy_copy'], function () { browserSync.init({ @@ -32,6 +34,11 @@ gulp.task('reload', function () { browserSync.reload(); }); +gulp.task('delete_folders', function(){ + return del(['libs/','public/','temp/','dist/']).then(function(paths){ + console.log('Deleted Files & folders ',paths); + }); +}); gulp.task('uglyfy_copy', function () { return rollup({ @@ -74,5 +81,5 @@ gulp.task('prepare_dist_folder', function () { }); gulp.task('release', function () { - runSequence('copylibs', 'copylibsDev', 'uglyfy_copy', 'prepare_dist_folder', 'zipFiles'); + runSequence('delete_folders','copylibs', 'copylibsDev', 'uglyfy_copy', 'prepare_dist_folder', 'zipFiles'); }); diff --git a/package-lock.json b/package-lock.json index f9bb142..f500980 100644 --- a/package-lock.json +++ b/package-lock.json @@ -204,6 +204,15 @@ "integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==", "dev": true }, + "array-union": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", + "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", + "dev": true, + "requires": { + "array-uniq": "1.0.3" + } + }, "array-uniq": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", @@ -1673,6 +1682,28 @@ } } }, + "del": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/del/-/del-3.0.0.tgz", + "integrity": "sha1-U+z2mf/LyzljdpGrE7rxYIGXZuU=", + "dev": true, + "requires": { + "globby": "6.1.0", + "is-path-cwd": "1.0.0", + "is-path-in-cwd": "1.0.1", + "p-map": "1.2.0", + "pify": "3.0.0", + "rimraf": "2.6.2" + }, + "dependencies": { + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true + } + } + }, "depd": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", @@ -2326,6 +2357,12 @@ "universalify": "0.1.2" } }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, "fsevents": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.4.tgz", @@ -3025,6 +3062,35 @@ "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==", "dev": true }, + "globby": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", + "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", + "dev": true, + "requires": { + "array-union": "1.0.2", + "glob": "7.1.2", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1" + }, + "dependencies": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + } + } + }, "globule": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/globule/-/globule-0.1.0.tgz", @@ -4101,6 +4167,30 @@ "lodash.isfinite": "3.3.2" } }, + "is-path-cwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", + "integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=", + "dev": true + }, + "is-path-in-cwd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.1.tgz", + "integrity": "sha512-FjV1RTW48E7CWM7eE/J2NJvAEEVektecDBVBE5Hh3nM1Jd0kvhHtX68Pr3xsDf857xt3Y4AkwVULK1Vku62aaQ==", + "dev": true, + "requires": { + "is-path-inside": "1.0.1" + } + }, + "is-path-inside": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz", + "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", + "dev": true, + "requires": { + "path-is-inside": "1.0.2" + } + }, "is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -4932,6 +5022,12 @@ "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true }, + "p-map": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-1.2.0.tgz", + "integrity": "sha512-r6zKACMNhjPJMTl8KcFH4li//gkrXWfbD6feV8l6doRHlzljFWGJ2AP6iKaCJXyZmAUMOPtvbW7EXkbWO/pLEA==", + "dev": true + }, "parse-filepath": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz", @@ -5029,6 +5125,12 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", + "dev": true + }, "path-parse": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", @@ -5429,6 +5531,31 @@ "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", "dev": true }, + "rimraf": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "dev": true, + "requires": { + "glob": "7.1.2" + }, + "dependencies": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + } + } + }, "rollup": { "version": "0.54.1", "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.54.1.tgz", diff --git a/package.json b/package.json index 48435d2..490f5eb 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "babel-preset-env": "^1.7.0", "babel-preset-es2015": "^6.24.1", "browser-sync": "^2.24.6", + "del": "^3.0.0", "gulp": "^3.9.1", "gulp-rollup": "^2.16.2", "gulp-size": "^3.0.0", -- cgit v1.2.3