From 327b26b3170d3133c826fbeb8ca4ba0ecfa0ddc5 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Mon, 10 Feb 2020 12:51:07 +0100 Subject: [PATCH] chore: use node script for cleaning scripts (#9547) --- package.json | 12 ++++++------ scripts/cleanE2e.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 scripts/cleanE2e.js diff --git a/package.json b/package.json index 73012caa1a79..dd7718786427 100644 --- a/package.json +++ b/package.json @@ -82,13 +82,13 @@ "which": "^2.0.1" }, "scripts": { - "build-clean": "rm -rf ./packages/*/build ./packages/*/build-es5 ./packages/*/tsconfig.tsbuildinfo", + "build-clean": "rimraf ./packages/*/build ./packages/*/build-es5 ./packages/*/tsconfig.tsbuildinfo", "prebuild": "yarn build:ts", "build": "node ./scripts/build.js", - "build:ts": "node scripts/buildTs.js", + "build:ts": "node ./scripts/buildTs.js", "check-copyright-headers": "node ./scripts/checkCopyrightHeaders.js", - "clean-all": "rm -rf ./node_modules && rm -rf ./packages/*/node_modules && yarn clean-e2e && yarn build-clean", - "clean-e2e": "find ./e2e -not \\( -path ./e2e/presets/js -prune \\) -not \\( -path ./e2e/presets/json -prune \\) -not \\( -path ./e2e/global-setup-node-modules -prune \\) -mindepth 1 -type d \\( -name node_modules -prune \\) -exec rm -r '{}' +", + "clean-all": "rimraf ./node_modules && rimraf ./packages/*/node_modules && yarn clean-e2e && yarn build-clean", + "clean-e2e": "node ./scripts/cleanE2e.js", "jest": "node ./packages/jest-cli/bin/jest.js", "jest-coverage": "yarn jest --coverage", "lint": "eslint . --cache --ext js,jsx,ts,tsx,md", @@ -96,10 +96,10 @@ "lint:prettier": "yarn --silent lint:prettier:ci --fix", "lint:prettier:ci": "prettylint '**/*.{md,yml,yaml}' --ignore-path .gitignore", "postinstall": "opencollective postinstall && yarn build", - "install-no-ts-build": "node scripts/remove-postinstall && yarn --no-progress --frozen-lockfile && node scripts/build", + "install-no-ts-build": "node ./scripts/remove-postinstall && yarn --no-progress --frozen-lockfile && node ./scripts/build", "publish": "yarn build-clean && yarn build && lerna publish --silent", "test-ci-es5-build-in-browser": "karma start --single-run", - "test-ci": "yarn jest-coverage --color -i --config jest.config.ci.js && yarn test-leak && node scripts/mapCoverage.js && codecov", + "test-ci": "yarn jest-coverage --color -i --config jest.config.ci.js && yarn test-leak && node ./scripts/mapCoverage.js && codecov", "test-ci-partial": "yarn jest --color -i --config jest.config.ci.js", "test-pretty-format-perf": "node packages/pretty-format/perf/test.js", "test-leak": "yarn jest -i --detectLeaks jest-mock jest-diff jest-repl", diff --git a/scripts/cleanE2e.js b/scripts/cleanE2e.js new file mode 100644 index 000000000000..e45d32d8b2b8 --- /dev/null +++ b/scripts/cleanE2e.js @@ -0,0 +1,28 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +const {normalize, resolve} = require('path'); +const {sync: glob} = require('glob'); +const {sync: rimraf} = require('rimraf'); + +const blacklist = [ + 'e2e/global-setup-node-modules/node_modules/', + 'e2e/presets/js/node_modules/', + 'e2e/presets/json/node_modules/', +].map(dir => normalize(dir)); + +const e2eNodeModules = glob('e2e/*/node_modules/') + .concat(glob('e2e/*/*/node_modules/')) + .filter(dir => !blacklist.includes(dir)) + .map(dir => resolve(__dirname, '..', dir)) + .sort(); + +e2eNodeModules.forEach(dir => { + rimraf(dir, {glob: false}); +});