Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const outFiles: {
[fileName: string]: BasicGeneratedFile;
} = {};
if (
nextToSources ||
(fs.existsSync(outputPath) && fs.statSync(outputPath).isDirectory())
) {
if (options.globalTypesFile) {
const globalTypesDir = path.dirname(options.globalTypesFile);
if (!fs.existsSync(globalTypesDir)) {
fs.mkdirSync(globalTypesDir);
}
} else if (nextToSources && !fs.existsSync(outputPath)) {
fs.mkdirSync(outputPath);
}
const globalSourcePath =
options.globalTypesFile ||
path.join(
outputPath,
`globalTypes.${options.tsFileExtension ||
TYPESCRIPT_DEFAULT_FILE_EXTENSION}`
);
outFiles[globalSourcePath] = {
output: generatedGlobalFile.fileContents
};
generatedFiles.forEach(({ sourcePath, fileName, content }) => {
let dir = outputPath;
if (nextToSources) {
generatedFiles.forEach(({ sourcePath, fileName, content }) => {
let dir = outputPath;
if (nextToSources) {
dir = path.join(
path.dirname(path.relative(rootPath, toPath(sourcePath))),
dir
);
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
}
const outFilePath = path.join(dir, fileName);
outFiles[outFilePath] = {
output: content({ outputPath: outFilePath, globalSourcePath })
.fileContents
};
});
generatedFiles.forEach(({ sourcePath, fileName, content }) => {
const dir = path.join(
path.dirname(path.posix.relative(rootPath, toPath(sourcePath))),
outputPath
);
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
outFiles[path.join(dir, fileName)] = {
output: content.fileContents + common
};
});
const context = compileToIR(schema, document, options);
const generatedFiles = generateTypescriptLocalSource(context);
const generatedGlobalFile = generateTypescriptGlobalSource(context);
const outFiles: {
[fileName: string]: BasicGeneratedFile;
} = {};
if (
nextToSources ||
(fs.existsSync(outputPath) && fs.statSync(outputPath).isDirectory())
) {
if (options.globalTypesFile) {
const globalTypesDir = path.dirname(options.globalTypesFile);
if (!fs.existsSync(globalTypesDir)) {
fs.mkdirSync(globalTypesDir);
}
} else if (nextToSources && !fs.existsSync(outputPath)) {
fs.mkdirSync(outputPath);
}
const globalSourcePath =
options.globalTypesFile ||
path.join(
outputPath,
`globalTypes.${options.tsFileExtension ||
TYPESCRIPT_DEFAULT_FILE_EXTENSION}`
);
outFiles[globalSourcePath] = {
output: generatedGlobalFile.fileContents
};