1
0
Fork 0
mirror of https://github.com/imjasonh/scad-to-png synced 2026-07-07 01:22:23 +00:00

Use SCAD file modification time in generated READMEs

Instead of using the current timestamp, use the modification time of the
source SCAD file. This ensures READMEs only change when their source
files change, making the outputs more deterministic and avoiding
unnecessary changes in version control.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jason Hall 2025-06-20 19:42:26 -04:00
parent 73954341fd
commit 179644ef8f
Failed to extract signature
4 changed files with 10 additions and 6 deletions

View file

@ -1,6 +1,6 @@
# gear.scad - Rendered Output
Generated on: 2025-06-20T23:32:34.685Z
Generated on: 2025-06-20T21:04:40.269Z
## 3D Model

View file

@ -1,6 +1,6 @@
# parametric-box.scad - Rendered Output
Generated on: 2025-06-20T23:32:35.030Z
Generated on: 2025-06-20T22:13:05.407Z
## 3D Model

View file

@ -1,6 +1,6 @@
# simple-box.scad - Rendered Output
Generated on: 2025-06-20T23:32:35.342Z
Generated on: 2025-06-20T21:04:31.703Z
## 3D Model

View file

@ -112,8 +112,8 @@ function renderStlToPng(stlBuffer, viewConfig, outputPath, width, height) {
}
}
function generateReadme(scadFileName, stlFileName, views) {
const timestamp = new Date().toISOString();
function generateReadme(scadFileName, stlFileName, views, scadFileMtime) {
const timestamp = scadFileMtime.toISOString();
let content = `# ${scadFileName} - Rendered Output\n\n`;
content += `Generated on: ${timestamp}\n\n`;
@ -141,6 +141,10 @@ async function main() {
process.exit(1);
}
// Get file stats for modification time
const stats = await fs.stat(inputFile);
const scadFileMtime = stats.mtime;
// Read SCAD file
const scadContent = await fs.readFile(inputFile, 'utf8');
@ -189,7 +193,7 @@ async function main() {
// Generate README.md with embedded images
const readmePath = path.join(options.output, 'README.md');
const readmeContent = generateReadme(path.basename(inputFile), stlFileName, views);
const readmeContent = generateReadme(path.basename(inputFile), stlFileName, views, scadFileMtime);
await fs.writeFile(readmePath, readmeContent);
console.log('Generated README.md');