How to use the ini.parse function in ini

To help you get started, we’ve selected a few ini 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 jonschlinkert / data-store / examples / ini.js View on Github external
function readParseFile() {
  let data;
  
  console.log('readParseFile');
  try {
    data = fs.readFileSync(this.path, 'utf-8');
  } catch (e) {
    console.log('readParseFile error; starting with empty data');
    data = {};
  }

  // Parse the INI-format configuration file
  return ini.parse(data);
}
github TencentCloudBase / cloudbase-cli / src / utils.ts View on Github external
export async function getMetadata() {
    if (fs.existsSync(TCBRC)) {
        const tcbrc = ini.parse(fs.readFileSync(TCBRC, 'utf-8'))
        if (!tcbrc.secretId || !tcbrc.secretKey || !tcbrc.host || !tcbrc.password || !tcbrc.username || !tcbrc.port) {
            // 缺少信息,重新登录
            return await login()
        }
        return tcbrc
    } else {
        // 没有登录过
        return await login()
    }
}
github SSilence / sum / app / sum-init.js View on Github external
$(document).ready(function() {
    
    // read config
    
    // get default config
    config = ini.parse(fs.readFileSync('./app/default.ini', 'utf-8'));

    // helper returns true if file exists, false otherwise
    var fileExists = function(filename) {
        try {
            fs.accessSync(filename);
        } catch(e) {
            return false;
        }
        return true;
    };
    
    // for linux or osx overwrite values from ~/.sum.ini configuration file
    if (os.platform() == 'linux' || os.platform() == 'darwin')
        if (fileExists(process.env.HOME + '/.sum.ini'))
            $.extend(config, ini.parse(fs.readFileSync(process.env.HOME + '/.sum.ini', 'utf-8')));
github zumwald / better-vsts-npm-auth / lib / npm.ts View on Github external
fs.readFile(that.filePath, "utf8", (err, data) => {
        if (err && err.code !== "ENOENT") {
          reject(err);
        } else {
          try {
            console.log("config from", that.filePath);
            that.settings = ini.parse(data || "");

            if (that.settings[""]) {
              delete that.settings[""];
            }

            resolve(that);
          } catch (e) {
            reject(e);
          }
        }
      });
    });
github Nexmo / nexmo-cli / src / config.js View on Github external
read() {
    this.credentials = ini.parse(
      fs.readFileSync(this.readFilename(), 'utf-8')
    );
    return this.credentials;
  }
github marmelab / comfygure / admin / config / webpack.config.cmd.js View on Github external
function getConfig() {
    try {
        require.resolve(path.resolve(process.cwd(), './.comfy/config'));
    } catch (e) {
        return { project: {} };
    }
    return ini.parse(fs.readFileSync(path.resolve(process.cwd(), './.comfy/config'), 'utf-8'));
}
github sindresorhus / global-dirs / index.js View on Github external
const readRc = filePath => {
	try {
		return ini.parse(fs.readFileSync(filePath, 'utf8')).prefix;
	} catch (_) {}
};
github electrode-io / fyn / cli / load-rc.js View on Github external
function readRc(fname) {
  const rcFname = Path.basename(fname);

  try {
    const rcData = Fs.readFileSync(fname).toString();
    let rc;

    try {
      assert(rcFname === ".fynrc" && rcData.startsWith("---"));
      rc = Yaml.parse(rcData);
      logger.debug(`Loaded ${rcFname} YAML RC`, fname, JSON.stringify(rc));
    } catch (e) {
      rc = Ini.parse(rcData);
      logger.debug(`Loaded ${rcFname} ini RC`, fname, JSON.stringify(rc));
    }

    return rc;
  } catch (e) {
    if (e.code !== "ENOENT") {
      logger.error(`Failed to process ${rcFname} RC file`, fname, e.message);
    }
    return {};
  }
}
github platformio / platformio-atom-ide / lib / import-arduino-project / command.js View on Github external
function modifyPlatformioIni() {
      if (!keepCompatible && !useArduinoLibManager) {
        return;
      }
      const iniPath = path.join(projectPath, 'platformio.ini');

      let contentToPreserve = '';
      const fullConfig = fs.readFileSync(iniPath).toString();
      const envPosition = fullConfig.search(/^\[env:/m);
      if (envPosition > -1) {
        contentToPreserve = fullConfig.slice(0, envPosition);
      }

      const config = ini.parse(fullConfig);
      if (!config.platformio) {
        config.platformio = {};
      }

      if (keepCompatible) {
        config.platformio.src_dir = path.basename(projectPath);
      }
      if (useArduinoLibManager) {
        config.platformio.lib_dir = view.getLibManagerDirectory();
      }

      fs.writeFileSync(iniPath, contentToPreserve);
      fs.appendFileSync(iniPath, ini.stringify(config));
    }
github aws-amplify / amplify-cli / packages / amplify-provider-awscloudformation / lib / system-config-manager.js View on Github external
function getProfileCredentials(profileName) {
  let profileCredentials;
  if (fs.existsSync(credentialsFilePath)) {
    const credentials = ini.parse(fs.readFileSync(credentialsFilePath, 'utf-8'));

    Object.keys(credentials).forEach(key => {
      const keyName = key.trim();
      if (profileName === keyName) {
        profileCredentials = credentials[key];
      }
    });
  }
  return normalizeKeys(profileCredentials);
}

ini

An ini encoder/decoder for node

ISC
Latest version published 21 hours ago

Package Health Score

92 / 100
Full package analysis