How to use the apollo-codegen-core/lib/localfs.fs.mkdirSync function in apollo-codegen-core

To help you get started, we’ve selected a few apollo-codegen-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apollographql / apollo-tooling / packages / apollo / src / generate.ts View on Github external
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) {
github apollographql / apollo-tooling / packages / apollo / src / generate.ts View on Github external
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
        };
      });
github apollographql / apollo-tooling / packages / apollo / src / generate.ts View on Github external
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
        };
      });
github apollographql / apollo-tooling / packages / apollo / src / generate.ts View on Github external
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
      };