ci: correctly check for outputPaths to exist before deleting them (#64137)

Properly check if the output paths for each npm package exists before ensuring they are deleted when building all packages

PR Close #64137
This commit is contained in:
Joey Perrott 2025-09-29 09:54:13 -06:00 committed by kirjs
parent 3b28ee1daa
commit 78cee8eca3

View file

@ -6,10 +6,11 @@
* found in the LICENSE file at https://angular.dev/license
*/
import {execSync, spawnSync} from 'child_process';
import {execSync} from 'child_process';
import {join, dirname} from 'path';
import {BuiltPackage} from '@angular/ng-dev';
import {fileURLToPath} from 'url';
import {existsSync, lstatSync} from 'fs';
/** Path to the project directory. */
export const projectDir: string = join(dirname(fileURLToPath(import.meta.url)), '../..');
@ -72,7 +73,7 @@ function buildReleasePackages(
// do this to ensure that the version placeholders are properly populated.
packageNames.forEach((pkgName) => {
const outputPath = getBazelOutputPath(pkgName);
if (spawnSync(`[ -d ${outputPath} ]`).status !== 0) {
if (existsSync(outputPath) && lstatSync(outputPath).isDirectory()) {
exec(`chmod -R u+w ${outputPath}`);
exec(`rm -rf ${outputPath}`);
}