node_modules.graphql-config.lib.findGraphQLConfigFile.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apollo-client-maven-plugin Show documentation
Show all versions of apollo-client-maven-plugin Show documentation
Maven plugin for generating graphql clients
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var path_1 = require("path");
var fs_1 = require("fs");
var errors_1 = require("./errors");
exports.GRAPHQL_CONFIG_NAME = '.graphqlconfig';
exports.GRAPHQL_CONFIG_YAML_NAME = '.graphqlconfig.yaml';
exports.GRAPHQL_CONFIG_YML_NAME = '.graphqlconfig.yml';
function isRootDir(path) {
return path_1.dirname(path) === path;
}
function findGraphQLConfigFile(filePath) {
filePath = path_1.resolve(filePath);
if (filePath.endsWith(exports.GRAPHQL_CONFIG_NAME) ||
filePath.endsWith(exports.GRAPHQL_CONFIG_YAML_NAME) ||
filePath.endsWith(exports.GRAPHQL_CONFIG_YML_NAME)) {
return filePath;
}
var currentDir = filePath;
while (!isRootDir(currentDir)) {
var configPath = path_1.join(currentDir, exports.GRAPHQL_CONFIG_NAME);
if (fs_1.existsSync(configPath)) {
return configPath;
}
if (fs_1.existsSync(configPath + '.yaml')) {
return configPath + '.yaml';
}
if (fs_1.existsSync(configPath + '.yml')) {
return configPath + '.yml';
}
currentDir = path_1.dirname(currentDir);
}
throw new errors_1.ConfigNotFoundError("\"" + exports.GRAPHQL_CONFIG_NAME + "\" file is not available in the provided config " +
("directory: " + filePath + "\nPlease check the config directory."));
}
exports.findGraphQLConfigFile = findGraphQLConfigFile;
© 2015 - 2025 Weber Informatics LLC | Privacy Policy