From 91b94c812834753adced4f1a8be0e6fc8937bb1f Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Mon, 14 Jun 2021 16:58:32 +0200 Subject: [PATCH] chore: use a script for removing examples directory --- package.json | 2 +- scripts/remove-examples.js | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 scripts/remove-examples.js diff --git a/package.json b/package.json index 5beeff419ec1..42f7ffe04460 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "lint": "eslint . --cache --ext js,jsx,ts,tsx,md", "lint:prettier": "prettier '**/*.{md,yml,yaml}' 'website/**/*.{css,js}' --write --ignore-path .gitignore", "lint:prettier:ci": "prettier '**/*.{md,yml,yaml}' 'website/**/*.{css,js}' --check --ignore-path .gitignore", - "remove-examples": "rimraf examples/", + "remove-examples": "node ./scripts/remove-examples.js", "test-types": "yarn jest --config jest.config.types.js", "test-ci": "yarn jest-coverage --color -i --config jest.config.ci.js && yarn test-leak && node ./scripts/mapCoverage.js && codecov", "test-ci-partial": "yarn test-ci-partial:parallel -i", diff --git a/scripts/remove-examples.js b/scripts/remove-examples.js new file mode 100644 index 000000000000..d77654f6fdc9 --- /dev/null +++ b/scripts/remove-examples.js @@ -0,0 +1,22 @@ +/** + * 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 {writeFileSync} = require('fs'); +const {resolve} = require('path'); +const rimraf = require('rimraf'); + +const configFile = require.resolve('../jest.config'); + +const config = require(configFile); + +delete config.projects; + +writeFileSync(configFile, `module.exports = ${JSON.stringify(config)};\n`); + +rimraf.sync(resolve(__dirname, '../examples/'));