From 2d638e5da7e3efd956ffdc38b17a41ed2caf6ea3 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 20 Mar 2017 10:32:16 -0700 Subject: [PATCH] Add option to clean.py to only remove dist and out dirs --- docs/development/build-instructions-linux.md | 2 +- docs/development/build-instructions-osx.md | 2 +- .../development/build-instructions-windows.md | 2 +- package.json | 2 +- script/clean-build.py | 18 ---------- script/clean.py | 36 +++++++++++++++---- 6 files changed, 33 insertions(+), 29 deletions(-) delete mode 100755 script/clean-build.py diff --git a/docs/development/build-instructions-linux.md b/docs/development/build-instructions-linux.md index 296f08ab197..e6b5004bf28 100644 --- a/docs/development/build-instructions-linux.md +++ b/docs/development/build-instructions-linux.md @@ -123,7 +123,7 @@ To clean only `out` and `dist` directories: $ npm run clean-build ``` -Note that both commands will require to do run bootstrap again . +**Note:** Both clean commands require running `bootstrap` again before building. ## Troubleshooting diff --git a/docs/development/build-instructions-osx.md b/docs/development/build-instructions-osx.md index 2d7cc36db6f..d0e95aaf18c 100644 --- a/docs/development/build-instructions-osx.md +++ b/docs/development/build-instructions-osx.md @@ -91,7 +91,7 @@ To clean only `out` and `dist` directories: $ npm run clean-build ``` -Note that both commands will require to do run bootstrap again . +**Note:** Both clean commands require running `bootstrap` again before building. ## Tests diff --git a/docs/development/build-instructions-windows.md b/docs/development/build-instructions-windows.md index c66b8b423dc..4f7335e108f 100644 --- a/docs/development/build-instructions-windows.md +++ b/docs/development/build-instructions-windows.md @@ -89,7 +89,7 @@ To clean only `out` and `dist` directories: $ npm run clean-build ``` -Note that both commands will require to do run bootstrap again . +**Note:** Both clean commands require running `bootstrap` again before building. ## Tests diff --git a/package.json b/package.json index ef0a405fb42..8de882fbf5f 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "bump-version": "./script/bump-version.py", "build": "python ./script/build.py -c D", "clean": "python ./script/clean.py", - "clean-build": "python ./script/clean-build.py", + "clean-build": "python ./script/clean.py --build", "coverage": "npm run instrument-code-coverage && npm test -- --use-instrumented-asar", "instrument-code-coverage": "electabul instrument --input-path ./lib --output-path ./out/coverage/electron.asar", "lint": "npm run lint-js && npm run lint-cpp && npm run lint-py && npm run lint-api-docs-js && npm run lint-api-docs", diff --git a/script/clean-build.py b/script/clean-build.py deleted file mode 100755 index 7dad790daf0..00000000000 --- a/script/clean-build.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python - -import os -import sys - -from lib.util import rm_rf - - -SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) - - -def main(): - os.chdir(SOURCE_ROOT) - rm_rf('dist') - rm_rf('out') - -if __name__ == '__main__': - sys.exit(main()) diff --git a/script/clean.py b/script/clean.py index 669b6b4dd5f..c63bdbbadee 100755 --- a/script/clean.py +++ b/script/clean.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import argparse import os import sys @@ -11,13 +12,34 @@ SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) def main(): os.chdir(SOURCE_ROOT) - rm_rf('node_modules') - rm_rf('dist') - rm_rf('out') - rm_rf('spec/node_modules') - rm_rf('vendor/brightray/vendor/download/libchromiumcontent') - rm_rf('vendor/brightray/vendor/libchromiumcontent/src') - rm_rf(os.path.expanduser('~/.node-gyp')) + + args = parse_args() + + remove_directory('dist') + remove_directory('out') + + if not args.build: + remove_directory('node_modules') + remove_directory('spec/node_modules') + + remove_directory('vendor/brightray/vendor/download/libchromiumcontent') + remove_directory('vendor/brightray/vendor/libchromiumcontent/src') + + remove_directory(os.path.expanduser('~/.node-gyp')) + + +def parse_args(): + parser = argparse.ArgumentParser(description='Remove generated and' \ + 'downloaded build files') + parser.add_argument('-b', '--build', + help='Only remove out and dist directories', + action='store_true') + return parser.parse_args() + + +def remove_directory(directory): + print 'Removing %s' % directory + rm_rf(directory) if __name__ == '__main__':