Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphql-language-service-config

Package Overview
Dependencies
Maintainers
3
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-language-service-config - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

128

dist/index.js

@@ -96,30 +96,19 @@ 'use strict';

var GraphQLRC = exports.GraphQLRC = function () {
function GraphQLRC(graphqlrc, root) {
var _this = this;
var GraphQLRC = exports.GraphQLRC = function GraphQLRC(graphqlrc, root) {
var _this = this;
_classCallCheck(this, GraphQLRC);
_classCallCheck(this, GraphQLRC);
this._graphqlrc = graphqlrc;
this._rootDir = root;
this._configs = {};
if (this._graphqlrc[CONFIG_LIST_NAME]) {
Object.keys(this._graphqlrc[CONFIG_LIST_NAME]).forEach(function (name) {
_this._configs[name] = new GraphQLConfig(name, _this._graphqlrc[CONFIG_LIST_NAME][name], _this._rootDir);
});
}
}
GraphQLRC.prototype.getConfigDir = function getConfigDir() {
return this._rootDir;
this.getConfigDir = function () {
return _this._rootDir;
};
GraphQLRC.prototype.getConfigNames = function getConfigNames() {
return Object.keys(this._graphqlrc[CONFIG_LIST_NAME]);
this.getConfigNames = function () {
return Object.keys(_this._graphqlrc[CONFIG_LIST_NAME]);
};
GraphQLRC.prototype.getConfig = function getConfig(name) {
var config = this._configs[name];
this.getConfig = function (name) {
var config = _this._configs[name];
if (config === undefined) {
throw new Error('Config ' + name + ' not defined. Choose one of: ' + Object.keys(this._graphqlrc[CONFIG_LIST_NAME]).join(', '));
throw new Error('Config ' + name + ' not defined. Choose one of: ' + Object.keys(_this._graphqlrc[CONFIG_LIST_NAME]).join(', '));
}

@@ -129,64 +118,71 @@ return config;

GraphQLRC.prototype.getConfigByFilePath = function getConfigByFilePath(filePath) {
var _this2 = this;
var name = this.getConfigNames().find(function (configName) {
return _this2.getConfig(configName).isFileInInputDirs(filePath);
this.getConfigByFilePath = function (filePath) {
var name = _this.getConfigNames().find(function (configName) {
return _this.getConfig(configName).isFileInInputDirs(filePath);
});
return name ? this._configs[name] : null;
return name ? _this._configs[name] : null;
};
return GraphQLRC;
}();
this._graphqlrc = graphqlrc;
this._rootDir = root;
this._configs = {};
if (this._graphqlrc[CONFIG_LIST_NAME]) {
Object.keys(this._graphqlrc[CONFIG_LIST_NAME]).forEach(function (name) {
_this._configs[name] = new GraphQLConfig(name, _this._graphqlrc[CONFIG_LIST_NAME][name], _this._rootDir);
});
}
};
var GraphQLConfig = exports.GraphQLConfig = function () {
function GraphQLConfig(name, config, rootDir) {
var _this2 = this;
_classCallCheck(this, GraphQLConfig);
this._name = name;
this._rootDir = rootDir;
this._config = config;
}
this.getRootDir = function () {
return _this2._rootDir;
};
GraphQLConfig.prototype.getRootDir = function getRootDir() {
return this._rootDir;
};
this.getName = function () {
return _this2._name;
};
GraphQLConfig.prototype.getName = function getName() {
return this._name;
};
this.getConfig = function () {
return _this2._config;
};
GraphQLConfig.prototype.getConfig = function getConfig() {
return this._config;
};
this.getInputDirs = function () {
return _this2._config['input-dirs'] ? _this2._config['input-dirs'] : [];
};
GraphQLConfig.prototype.getInputDirs = function getInputDirs() {
return this._config['input-dirs'] ? this._config['input-dirs'] : [];
};
this.getExcludeDirs = function () {
return _this2._config['exclude-dirs'] ? _this2._config['exclude-dirs'] : [];
};
GraphQLConfig.prototype.getExcludeDirs = function getExcludeDirs() {
return this._config['exclude-dirs'] ? this._config['exclude-dirs'] : [];
};
this.isFileInInputDirs = function (fileName) {
if (!_this2.getInputDirs()) {
return false;
}
return _this2.getInputDirs().some(function (dirPath) {
return fileName.indexOf(dirPath) !== -1;
});
};
GraphQLConfig.prototype.isFileInInputDirs = function isFileInInputDirs(fileName) {
if (!this.getInputDirs()) {
return false;
}
return this.getInputDirs().some(function (dirPath) {
return fileName.indexOf(dirPath) !== -1;
});
};
this.getSchemaPath = function () {
return _this2._config[SCHEMA_PATH] || null;
};
GraphQLConfig.prototype.getSchemaPath = function getSchemaPath() {
return this._config[SCHEMA_PATH] || null;
};
this.getCustomValidationRulesModulePath = function () {
var modulePath = _this2._config[CUSTOM_VALIDATION_RULES_MODULE_PATH];
if (!modulePath) {
return null;
}
return _this2._normalizePath(modulePath);
};
GraphQLConfig.prototype.getCustomValidationRulesModulePath = function getCustomValidationRulesModulePath() {
var modulePath = this._config[CUSTOM_VALIDATION_RULES_MODULE_PATH];
if (!modulePath) {
return null;
}
return this._normalizePath(modulePath);
};
this._name = name;
this._rootDir = rootDir;
this._config = config;
}

@@ -193,0 +189,0 @@ GraphQLConfig.prototype._normalizePath = function _normalizePath(modulePath) {

{
"name": "graphql-language-service-config",
"repository": "https://github.com/graphql/graphql-language-service",
"version": "0.0.2",
"version": "0.0.3",
"description": "A tool-kit for accessing and using `.graphqlrc` configuration files",

@@ -6,0 +6,0 @@ "contributors": [

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc