Skip to content

Commit f11cc37

Browse files
[docs-infra] Ensure create-playground script only runs if target file is absent (#19603)
1 parent fecb8b0 commit f11cc37

File tree

4 files changed

+24
-148
lines changed

4 files changed

+24
-148
lines changed

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"deploy": "git push -f upstream master:docs-v8",
1111
"icons": "rimraf public/static/icons/* && node ./scripts/buildIcons.js",
1212
"serve": "serve ./export -l 3010",
13-
"create-playground": "cpy --cwd=scripts playground.template.tsx ../../pages/playground --rename=index.tsx",
13+
"create-playground": "node ./scripts/createPlayground.js",
1414
"typescript": "tsc -p tsconfig.json",
1515
"typescript:transpile": "cross-env BABEL_ENV=development node scripts/formattedTSDemos",
1616
"typescript:transpile:dev": "cross-env BABEL_ENV=development node scripts/formattedTSDemos --watch",

docs/scripts/createPlayground.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
const sourceFile = path.join(__dirname, 'playground.template.tsx');
5+
const targetFile = path.join(process.cwd(), 'pages/playground/index.tsx');
6+
const targetDir = path.dirname(targetFile);
7+
8+
if (fs.existsSync(targetFile)) {
9+
// eslint-disable-next-line no-console
10+
console.log('File already exists, skipping copy\n');
11+
process.exit(0);
12+
}
13+
14+
try {
15+
fs.mkdirSync(targetDir, { recursive: true });
16+
fs.copyFileSync(sourceFile, targetFile);
17+
18+
// eslint-disable-next-line no-console
19+
console.log('✅ File copied successfully\n');
20+
} catch (error) {
21+
console.error('❌ Error copying file:', error.message);
22+
process.exit(1);
23+
}

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115
"chai-dom": "^1.12.1",
116116
"compression-webpack-plugin": "^11.1.0",
117117
"concurrently": "^9.2.1",
118-
"cpy-cli": "^5.0.0",
119118
"cross-env": "catalog:",
120119
"danger": "^13.0.4",
121120
"date-fns-jalali-v2": "npm:[email protected]",

pnpm-lock.yaml

Lines changed: 0 additions & 146 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)