diff --git a/src/utils/Processing.ts b/src/utils/Processing.ts index e774878c1..1a9de87a7 100644 --- a/src/utils/Processing.ts +++ b/src/utils/Processing.ts @@ -632,8 +632,9 @@ export function writeFSHIndex( // write txt with nice formatting textIndex.unshift(['Output File', 'Name', 'Type', 'FSH File', 'Lines']); fs.outputFileSync(path.join(outDir, 'fsh-generated', 'fsh-index.txt'), table(textIndex)); - // write json for machine usage - fs.outputJsonSync(path.join(outDir, 'fsh-generated', 'fsh-index.json'), jsonIndex, { spaces: 2 }); + // write json for machine usage. Use the fsh-generated/data folder for the template to pick it up. Ensure the folder exists + fs.ensureDirSync(path.join(outDir, 'fsh-generated', 'data')); + fs.outputJsonSync(path.join(outDir, 'fsh-generated', 'data', 'fsh-index.json'), jsonIndex, { spaces: 2 }); } export function writePreprocessedFSH(outDir: string, inDir: string, tank: FSHTank) { diff --git a/test/utils/Processing.test.ts b/test/utils/Processing.test.ts index eb4b1087e..0d1d02466 100644 --- a/test/utils/Processing.test.ts +++ b/test/utils/Processing.test.ts @@ -1675,7 +1675,7 @@ describe('Processing', () => { it('should create text and json index files that contain each resource in the package', () => { writeFSHIndex(tempIGPubRoot, outPackage, fshRoot, []); const textIndex = path.join(tempIGPubRoot, 'fsh-generated', 'fsh-index.txt'); - const jsonIndex = path.join(tempIGPubRoot, 'fsh-generated', 'fsh-index.json'); + const jsonIndex = path.join(tempIGPubRoot, 'fsh-generated', 'data', 'fsh-index.json'); expect(fs.existsSync(textIndex)).toBeTrue(); expect(fs.existsSync(jsonIndex)).toBeTrue(); @@ -1734,7 +1734,7 @@ describe('Processing', () => { it('should sort the list of resources by output file name', () => { writeFSHIndex(tempIGPubRoot, outPackage, fshRoot, []); const textIndex = path.join(tempIGPubRoot, 'fsh-generated', 'fsh-index.txt'); - const jsonIndex = path.join(tempIGPubRoot, 'fsh-generated', 'fsh-index.json'); + const jsonIndex = path.join(tempIGPubRoot, 'fsh-generated', 'data', 'fsh-index.json'); expect(fs.existsSync(textIndex)).toBeTrue(); expect(fs.existsSync(jsonIndex)).toBeTrue(); @@ -1757,7 +1757,7 @@ describe('Processing', () => { it('should not include a resource in the package if it is in the list of resources to skip', () => { writeFSHIndex(tempIGPubRoot, outPackage, fshRoot, ['StructureDefinition-my-extension.json']); const textIndex = path.join(tempIGPubRoot, 'fsh-generated', 'fsh-index.txt'); - const jsonIndex = path.join(tempIGPubRoot, 'fsh-generated', 'fsh-index.json'); + const jsonIndex = path.join(tempIGPubRoot, 'fsh-generated', 'data', 'fsh-index.json'); expect(fs.existsSync(textIndex)).toBeTrue(); expect(fs.existsSync(jsonIndex)).toBeTrue();