From e8eb30fa8b3c2e4575de6c9832cd91c7e14d7428 Mon Sep 17 00:00:00 2001 From: Christopher Allen Date: Wed, 23 Jun 2021 13:07:20 +0100 Subject: [PATCH] Script to clean release directory You can now do npm run clean:buildDir, ... clean:releaseDir, or just ... clean, which does both. The release directory is automatically cleaned before packaging commences. --- gulpfile.js | 6 +++- package.json | 2 ++ scripts/gulpfiles/build_tasks.js | 3 +- scripts/gulpfiles/package_tasks.js | 58 ++++++++++++++++++------------ 4 files changed, 44 insertions(+), 25 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index ccb9ed072..65cecb977 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -33,7 +33,11 @@ module.exports = { buildGenerators: buildTasks.generators, buildAdvancedCompilationTest: buildTasks.advancedCompilationTest, checkinBuilt: buildTasks.checkinBuilt, - clean: buildTasks.cleanBuildDir, + clean: gulp.series( + buildTasks.cleanBuildDir, + packageTasks.cleanReleaseDir), + cleanBuildDir: buildTasks.cleanBuildDir, + cleanReleaseDir: packageTasks.cleanReleaseDir, gitSyncDevelop: gitTasks.syncDevelop, gitSyncMaster: gitTasks.syncMaster, gitCreateRC: gitTasks.createRC, diff --git a/package.json b/package.json index 81925ec18..181613046 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,8 @@ "build:uncompressed": "gulp buildUncompressed", "bump": "npm --no-git-tag-version version 4.$(date +'%Y%m%d').0", "clean": "gulp clean", + "clean:build": "gulp cleanBuildDir", + "clean:release": "gulp cleanReleaseDir", "checkin": "gulp checkinBuilt", "deployDemos": "gulp deployDemos", "format": "git-clang-format", diff --git a/scripts/gulpfiles/build_tasks.js b/scripts/gulpfiles/build_tasks.js index e87b1cf69..ef1ca6ffc 100644 --- a/scripts/gulpfiles/build_tasks.js +++ b/scripts/gulpfiles/build_tasks.js @@ -559,8 +559,7 @@ function cleanBuildDir(done) { if (BUILD_DIR === '.' || BUILD_DIR === '/') { throw new Error(`Refusing to rm -rf ${BUILD_DIR}`); } - rimraf.sync(BUILD_DIR); - done(); + rimraf(BUILD_DIR, done); } module.exports = { diff --git a/scripts/gulpfiles/package_tasks.js b/scripts/gulpfiles/package_tasks.js index 84f79668c..de4c5dad0 100644 --- a/scripts/gulpfiles/package_tasks.js +++ b/scripts/gulpfiles/package_tasks.js @@ -366,33 +366,47 @@ function packageDTS() { .pipe(gulp.dest(`${RELEASE_DIR}`)); }; +/** + * This task cleans the release directory (by deleting it). + */ +function cleanReleaseDir(done) { + // Sanity check. + if (RELEASE_DIR === '.' || RELEASE_DIR === '/') { + throw new Error(`Refusing to rm -rf ${RELEASE_DIR}`); + } + rimraf(RELEASE_DIR, done); +} + /** * This task prepares the files to be included in the NPM by copying * them into the release directory. */ -const package = gulp.parallel( - packageIndex, - packageSources, - packageCompressed, - packageBrowser, - packageNode, - packageCore, - packageNodeCore, - packageBlockly, - packageBlocks, - packageJavascript, - packagePython, - packageLua, - packageDart, - packagePHP, - packageLocales, - packageMedia, - packageUMDBundle, - packageJSON, - packageReadme, - packageDTS -); +const package = gulp.series( + cleanReleaseDir, + gulp.parallel( + packageIndex, + packageSources, + packageCompressed, + packageBrowser, + packageNode, + packageCore, + packageNodeCore, + packageBlockly, + packageBlocks, + packageJavascript, + packagePython, + packageLua, + packageDart, + packagePHP, + packageLocales, + packageMedia, + packageUMDBundle, + packageJSON, + packageReadme, + packageDTS) + ); module.exports = { + cleanReleaseDir: cleanReleaseDir, package: package, };