Writes a configuration file in JavaScript format.
@param {Object} config The configuration object to write.
@param {string} filePath The filename to write to.
@throws {Error} If an error occurs linting the config file contents.
@returns {void}
@private
511759
function writeJSConfigFile(config, filePath) {
    debug(`Writing JS config file: ${filePath}`);

    let contentToWrite;
    const stringifiedContent = `module.exports = ${stringify(config, { cmp: sortByKey, space: 4 })};`;

    try {
        const CLIEngine = require("../cli-engine");
        const linter = new CLIEngine({
            baseConfig: config,
            fix: true,
            useEslintrc: false
        });
        const report = linter.executeOnText(stringifiedContent);

        contentToWrite = report.results[0].output || stringifiedContent;
    } catch (e) {
        debug("Error linting JavaScript config file, writing unlinted version");
        const errorMessage = e.message;

        contentToWrite = stringifiedContent;
        e.message = "An error occurred while generating your JavaScript config file. ";
        e.message += "A config file was still generated, but the config file itself may not follow your linting rules.";
        e.message += `\nError: ${errorMessage}`;
        throw e;
    } finally {
        fs.writeFileSync(filePath, contentToWrite, "utf8");
    }
}
830740
void writeJsFileToJsDir(TypeElement element, ElementVisitor visitor, String packagePath, String fn, String dir) {
		if (null != dir) {
			try (Writer w = fws.getFileObjectWriter(dir + File.separatorChar + "srvs", packagePath + "." + fn)) {
				messager.printMessage(Diagnostic.Kind.MANDATORY_WARNING, " javascript generation class : " + element + " to : " + dir);
				element.accept(visitor, w);
			} catch (IOException ioe) {
				messager.printMessage(Diagnostic.Kind.MANDATORY_WARNING, " FAILED TO CREATE : " + packagePath + "." + fn);
			}
		}
	}
263321
@SuppressWarnings("unchecked")
    @Override
    public T readConfig(String filePath) throws ConfigurationException {
        XStream xstream = new XStream(new StaxDriver());
        xstream.alias("configuration", clazz);
        return (T) xstream.fromXML(new File(filePath));
    }
1039293
function writeJSONConfigFile(config, filePath) {
    debug(`Writing JSON config file: ${filePath}`);

    const content = stringify(config, { cmp: sortByKey, space: 4 });

    fs.writeFileSync(filePath, content, "utf8");
}
1108666
function findConfigFile(filePath) {
		let prev = null
		do {
			const testPath = path.join(filePath, 'tsconfig.json')
			if (fs.existsSync(testPath)) {
				return testPath
			}
			prev = filePath
			filePath = path.dirname(filePath)
		} while (prev !== filePath)
		return undefined
	}
497282
def load_config(filename, filepath=''):
    

    FILE = path.join(filepath, filename)

    try:
        cfg.read(FILE)
        global _loaded
        _loaded = True
    except:
        print("configfile not found.")
1235202
public static void writeConfigFile(String fileName, boolean sortClasses) throws SQLException, IOException {
		List<Class<?>> classList = new ArrayList<Class<?>>();
		findAnnotatedClasses(classList, new File("."), 0);
		writeConfigFile(fileName, classList.toArray(new Class[classList.size()]), sortClasses);
	}
940320
function loadConfig(configToLoad) {
  var config = {};
  var filePath = '';

  if (configToLoad) {

    if (isObject(configToLoad)) {
      config = configToLoad;
    } else {
      filePath = configToLoad;
      config = readConfigFromFile(filePath);
    }

    if (!config.rules) {
      config.rules = {};
    }
    config.rules = Object.keys(config.rules).reduce(function(obj, ruleId) {
      if (!Array.isArray(config.rules[ruleId])) {
        obj[ruleId] = [config.rules[ruleId]];
      }
      return obj;
    }, {});

    validator.validate(config, filePath);

        // If an `extends` property is defined, it represents a configuration file to use as
        // a 'parent'. Load the referenced file and merge the configuration recursively.
    if (config.extends) {
      var configExtends = config.extends;

      if (!Array.isArray(config.extends)) {
        configExtends = [config.extends];
      }

            // Make the last element in an array take the highest precedence
      config = configExtends.reduceRight(function(previousValue, parentPath) {

        if (parentPath === 'nplint:recommended') {
                    // Add an explicit substitution for eslint:recommended to conf/eslint.json
                    // this lets us use the eslint.json file as the recommended rules
          parentPath = path.resolve(__dirname, '../conf/nplint.json');
        } else if (isFilePath(parentPath)) {
                  // If the `extends` path is relative, use the directory of the current configuration
                  // file as the reference point. Otherwise, use as-is.
          parentPath = (!isAbsolutePath(parentPath) ?
                    path.join(path.dirname(filePath), parentPath) :
                    parentPath
                );
        }

        try {
          return util.mergeConfigs(loadConfig(parentPath), previousValue);
        } catch (e) {
                  // If the file referenced by `extends` failed to load, add the path to the
                  // configuration file that referenced it to the error message so the user is
                  // able to see where it was referenced from, then re-throw
          e.message += '\nReferenced from: ' + filePath;
          throw e;
        }

      }, config);

    }

  }

  return config;
}
603697
def write(self):
        """"""
        with open(self.path, 'w') as f:
            self.config.write(f)
1124629
function writeJs(source, js, base) {
  var filename = path.basename(source, path.extname(source)) + '.js'
  var srcDir   = path.dirname(source)
  var baseDir  = srcDir.substring(base.length)
  var dir      = options.output ? path.join(options.output, baseDir) : srcDir
  var jsPath   = path.join(dir, filename)
  var compile  = function() {
    fs.writeFile(jsPath, js, function(err) {
      if(options.compile && options.watch) console.log("Compiled " + source)
    })
  }
  fs.exists(dir, function(exists) {
    exists ? compile() : exec("mkdir -p " + dir, compile)
  })
}
385157
function(config) {
        var self = this;

        return new Promise(function(resolve, reject) {
            if (self._options.output) {
                fs.writeFileAsync(self._options.output, config)
                    .then(function() {
                        resolve(config);
                    });
            } else {
                resolve(config);
            }
        });
    }
847144
function handleConfiguration(filePath) {
    if (fs.existsSync(filePath)) {
        filePath = path.resolve(filePath);
    }
    else {
        console.error('Invalid path to configuration file.');
        return 1;
    }
    return setupConfigurationFile(filePath);
}
972241
function injectScripts(filePath) {
  var contents = String($.fs.readFileSync(filePath));
  var fileExt = $.path.extname(filePath).substr(1);
  var fileType = fileTypes[fileExt] || fileTypes['default'];
  var returnType = /\r\n/.test(contents) ? '\r\n' : '\n';

  var newContents = contents.replace(
    fileType.block,
    replaceIncludes(filePath, fileType, returnType)
  );

  if (contents !== newContents) {
    $.fs.writeFileSync(filePath, newContents);

    config.get('on-file-updated')(filePath);
  }
}
638814
function writeFile(config, isJson, callback) {
  try {
    fs.writeFile('./.nplintrc', isJson ? JSON.stringify(config, null, 4) : yaml.safeDump(config), callback);
  } catch (e) {
    return callback(e);
  }
}
87418
public static void writeConfigFile(String fileName, Class<?>[] classes) throws SQLException, IOException {
		writeConfigFile(fileName, classes, false);
	}
118428
function writeConfigFile(config, yoRcPath = '.yo-rc.json') {
  let newYoRc = { ...config };
  if (FileUtils.doesFileExist(yoRcPath)) {
    const yoRc = JSON.parse(fs.readFileSync(yoRcPath, { encoding: 'utf-8' }));
    newYoRc = {
      ...yoRc,
      ...config,
      [GENERATOR_NAME]: {
        ...yoRc[GENERATOR_NAME],
        ...config[GENERATOR_NAME]
      }
    };
  }
  fs.writeFileSync(yoRcPath, JSON.stringify(newYoRc, null, 2));
}
17271
function loadJSONConfigFile(filePath) {
    debug(`Loading JSON config file: ${filePath}`);

    try {
        return JSON.parse(stripComments(readFile(filePath)));
    } catch (e) {
        debug(`Error reading JSON file: ${filePath}`);
        e.message = `Cannot read config file: ${filePath}\nError: ${e.message}`;
        e.messageTemplate = "failed-to-read-json";
        e.messageData = {
            path: filePath,
            message: e.message
        };
        throw e;
    }
}