diff options
| author | MirzaSamadAhmedBaig <[email protected]> | 2025-07-01 20:30:18 +0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-01 15:30:18 +0000 |
| commit | 01186e3afff0269f242a6732f53a3987b0ae1f3a (patch) | |
| tree | 818a4df92891ea64e2e69662898e69cf9af563d6 | |
| parent | a4062cb44aab771822fcc4d0fb772bbcde256c1d (diff) | |
Make clean script cross-platform (#1990)
Co-authored-by: Scott Densmore <[email protected]>
| -rw-r--r-- | packages/cli/package.json | 1 | ||||
| -rw-r--r-- | packages/core/package.json | 1 | ||||
| -rw-r--r-- | scripts/clean.js | 18 |
3 files changed, 15 insertions, 5 deletions
diff --git a/packages/cli/package.json b/packages/cli/package.json index ade14e16..fee5965b 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -10,7 +10,6 @@ }, "scripts": { "build": "node ../../scripts/build_package.js", - "clean": "rm -rf dist", "start": "node dist/index.js", "debug": "node --inspect-brk dist/index.js", "lint": "eslint . --ext .ts,.tsx", diff --git a/packages/core/package.json b/packages/core/package.json index e4a3a334..cababb8c 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -8,7 +8,6 @@ "scripts": { "start": "node dist/src/index.js", "build": "node ../../scripts/build_package.js", - "clean": "rm -rf dist", "lint": "eslint . --ext .ts,.tsx", "format": "prettier --write .", "test": "vitest run", diff --git a/scripts/clean.js b/scripts/clean.js index 51073edf..bb2cb678 100644 --- a/scripts/clean.js +++ b/scripts/clean.js @@ -17,10 +17,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { execSync } from 'child_process'; -import { rmSync } from 'fs'; +import { rmSync, readFileSync } from 'fs'; import { dirname, join } from 'path'; import { fileURLToPath } from 'url'; +import { globSync } from 'glob'; const __dirname = dirname(fileURLToPath(import.meta.url)); const root = join(__dirname, '..'); @@ -31,4 +31,16 @@ rmSync(join(root, 'packages/cli/src/generated/'), { recursive: true, force: true, }); -execSync('npm run clean --workspaces', { stdio: 'inherit', cwd: root }); +const RMRF_OPTIONS = { recursive: true, force: true }; +rmSync(join(root, 'bundle'), RMRF_OPTIONS); +// Dynamically clean dist directories in all workspaces +const rootPackageJson = JSON.parse( + readFileSync(join(root, 'package.json'), 'utf-8'), +); +for (const workspace of rootPackageJson.workspaces) { + const packages = globSync(join(workspace, 'package.json'), { cwd: root }); + for (const pkgPath of packages) { + const pkgDir = dirname(join(root, pkgPath)); + rmSync(join(pkgDir, 'dist'), RMRF_OPTIONS); + } +} |
