Skip to content

Commit

Permalink
fix: generic include should be inside root
Browse files Browse the repository at this point in the history
  • Loading branch information
martyanovandrey authored and 3y3 committed Nov 19, 2024
1 parent dc1d0fa commit ccaa6f5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/services/includers/batteries/generic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {dirname, join, parse} from 'path';
import {updateWith} from 'lodash';
import {dump} from 'js-yaml';

import {getRealPath} from '@diplodoc/transform/lib/utilsFS';

import {glob} from '../../../utils/glob';

import {IncluderFunctionParams} from '../../../models';
Expand Down Expand Up @@ -66,7 +68,14 @@ async function includerFunction(params: IncluderFunctionParams<Params>) {
cache,
}));

const writePath = join(writeBasePath, tocDirPath, item.include.path);
const writePath = getRealPath(join(writeBasePath, tocDirPath, item.include.path));

if (!writePath.startsWith(writeBasePath)) {
throw new GenericIncluderError(
`Expected the include path to be located inside project root, got: ${writePath}`,
writePath,
);
}

await mkdir(writePath, {recursive: true});

Expand Down

0 comments on commit ccaa6f5

Please sign in to comment.