fix(build): handle EEXIST errors in cpSync during bundle and build on Node.js 25+

This commit is contained in:
Sri Pasumarthi
2026-03-24 12:59:09 -07:00
parent 46fd7b4864
commit fbe8bcf535
2 changed files with 19 additions and 3 deletions
+4 -1
View File
@@ -18,7 +18,7 @@
// limitations under the License.
import { execSync } from 'node:child_process';
import { writeFileSync, existsSync, cpSync } from 'node:fs';
import { writeFileSync, existsSync, cpSync, rmSync } from 'node:fs';
import { join, basename } from 'node:path';
if (!process.cwd().includes('packages')) {
@@ -48,6 +48,9 @@ if (packageName === 'core') {
const docsSource = join(process.cwd(), '..', '..', 'docs');
const docsTarget = join(process.cwd(), 'dist', 'docs');
if (existsSync(docsSource)) {
if (existsSync(docsTarget)) {
rmSync(docsTarget, { recursive: true, force: true });
}
cpSync(docsSource, docsTarget, { recursive: true, dereference: true });
console.log('Copied documentation to dist/docs');
}
+15 -2
View File
@@ -17,7 +17,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { copyFileSync, existsSync, mkdirSync, cpSync } from 'node:fs';
import { copyFileSync, existsSync, mkdirSync, cpSync, rmSync } from 'node:fs';
import { dirname, join, basename } from 'node:path';
import { fileURLToPath } from 'node:url';
import { glob } from 'glob';
@@ -58,6 +58,9 @@ console.log(`Copied ${policyFiles.length} policy files to bundle/policies/`);
const docsSrc = join(root, 'docs');
const docsDest = join(bundleDir, 'docs');
if (existsSync(docsSrc)) {
if (existsSync(docsDest)) {
rmSync(docsDest, { recursive: true, force: true });
}
cpSync(docsSrc, docsDest, { recursive: true, dereference: true });
console.log('Copied docs to bundle/docs/');
}
@@ -66,6 +69,9 @@ if (existsSync(docsSrc)) {
const builtinSkillsSrc = join(root, 'packages/core/src/skills/builtin');
const builtinSkillsDest = join(bundleDir, 'builtin');
if (existsSync(builtinSkillsSrc)) {
if (existsSync(builtinSkillsDest)) {
rmSync(builtinSkillsDest, { recursive: true, force: true });
}
cpSync(builtinSkillsSrc, builtinSkillsDest, {
recursive: true,
dereference: true,
@@ -83,8 +89,12 @@ const devtoolsDest = join(
);
const devtoolsDistSrc = join(devtoolsSrc, 'dist');
if (existsSync(devtoolsDistSrc)) {
const targetDist = join(devtoolsDest, 'dist');
if (existsSync(targetDist)) {
rmSync(targetDist, { recursive: true, force: true });
}
mkdirSync(devtoolsDest, { recursive: true });
cpSync(devtoolsDistSrc, join(devtoolsDest, 'dist'), {
cpSync(devtoolsDistSrc, targetDist, {
recursive: true,
dereference: true,
});
@@ -99,6 +109,9 @@ if (existsSync(devtoolsDistSrc)) {
const bundleMcpSrc = join(root, 'packages/core/dist/bundled');
const bundleMcpDest = join(bundleDir, 'bundled');
if (existsSync(bundleMcpSrc)) {
if (existsSync(bundleMcpDest)) {
rmSync(bundleMcpDest, { recursive: true, force: true });
}
cpSync(bundleMcpSrc, bundleMcpDest, { recursive: true, dereference: true });
console.log('Copied bundled chrome-devtools-mcp to bundle/bundled/');
}