GeezerVison is showing github.com — fix(gs1): resolve generator paths from import.meta.url · u8array/ZPLab@b2e7dc5
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: scripts/gen-gs1-catalog.mjs +6-2Lines changed: 6 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | // Deterministic generator: GS1 Barcode Syntax Dictionary -> internal AI catalog. |
2 | 2 | // Source authoritative (GS1 AISBL, from BWIPP+Zint), matches bwip-js renderer. |
3 | 3 | import { readFileSync, writeFileSync } from 'node:fs'; |
4 | | -const src = readFileSync('scripts/data/gs1-syntax-dictionary.txt', 'utf8'); |
| 4 | +import { join } from 'node:path'; |
| 5 | +import { fileURLToPath } from 'node:url'; |
| 6 | + |
| 7 | +const ROOT = fileURLToPath(new URL('..', import.meta.url)); |
| 8 | +const src = readFileSync(join(ROOT, 'scripts', 'data', 'gs1-syntax-dictionary.txt'), 'utf8'); |
5 | 9 |
|
6 | 10 | function groupFor(ai) { |
7 | 11 | const p3 = ai.slice(0, 3); |
@@ -108,5 +112,5 @@ const header = `// GENERATED from the GS1 Barcode Syntax Dictionary (GS1 AISBL, |
108 | 112 | import type { Gs1AiCatalogEntry } from './gs1AiCatalog.types'; |
109 | 113 |
|
110 | 114 | export const GS1_AI_FULL_CATALOG: readonly Gs1AiCatalogEntry[] = [`; |
111 | | -writeFileSync('src/lib/gs1AiCatalog.ts', header + '\n' + out.map(toLine).join('\n') + '\n];\n'); |
| 115 | +writeFileSync(join(ROOT, 'src', 'lib', 'gs1AiCatalog.ts'), header + '\n' + out.map(toLine).join('\n') + '\n];\n'); |
112 | 116 | console.log('wrote src/lib/gs1AiCatalog.ts with', out.length, 'entries'); |