How to use the ini.stringify 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 balena-io-projects / boombeastic / app / index.js View on Github external
// Google Play Music config
  mopidy.gmusic.enabled = process.env.MOPIDY_GMUSIC_ENABLED === '1' ? true : false;
  mopidy.gmusic.username = process.env.MOPIDY_GMUSIC_USERNAME || "none";
  mopidy.gmusic.password = process.env.MOPIDY_GMUSIC_PASSWORD || "none";
  mopidy.gmusic.all_access = process.env.MOPIDY_GMUSIC_ALL_ACCESS === '1' ? true : false;
  // Spotify config
  mopidy.spotify.enabled = process.env.MOPIDY_SPOTIFY_ENABLED === '1' ? true : false;
  mopidy.spotify.username = process.env.MOPIDY_SPOTIFY_USERNAME || "none";
  mopidy.spotify.password = process.env.MOPIDY_SPOTIFY_PASSWORD || "none";
  // Soundcloud config
  mopidy.soundcloud.enabled = process.env.MOPIDY_SOUNDCLOUD_ENABLED === '1' ? true : false;
  mopidy.soundcloud.auth_token = process.env.MOPIDY_SOUNDCLOUD_AUTH_TOKEN || "none";
  // YouTube config
  mopidy.youtube.enabled = process.env.MOPIDY_YOUTUBE_ENABLED === '1' ? true : false;

  fs.writeFileSync('/etc/mopidy/mopidy.conf', ini.stringify(mopidy));
  fs.writeFileSync('/etc/shairport-sync.conf', 'general =\n{\nname = "BoomBeastic-' + process.env.RESIN_DEVICE_UUID.substring(0, 7) + '";\n};');

  // Mopidy
  console.log(chalk.cyan('starting Mopidy - HTTP port:' + mopidy.http.port + ' (proxy on port 80); MPD port:' + mopidy.mpd.port));
  display.init(() => {
    'use strict';
    display.image(display.presets.splash);
  });
  exec('systemctl start mopidy', (error, stdout, stderr) => {
    'use strict';
    if (error) {
      console.log(chalk.red(`exec error: ${error}`));
      return;
    }
  });
github TencentCloudBase / cloudbase-cli / lib / utils.js View on Github external
}
    // 存在临时密钥信息
    if (tcbrc.refreshToken) {
        // 临时密钥在 2 小时有效期内,可以直接使用
        if (Date.now() < tcbrc.tmpExpired) {
            const { tmpSecretId, tmpSecretKey, tmpToken } = tcbrc;
            return {
                secretId: tmpSecretId,
                secretKey: tmpSecretKey,
                token: tmpToken
            };
        }
        else if (Date.now() < tcbrc.expired) {
            // 临时密钥超过两小时有效期,但在 1 个月 refresh 有效期内,刷新临时密钥
            const credential = await auth_1.refreshTmpToken(tcbrc);
            fs.writeFileSync(constant_1.TCBRC, ini.stringify(credential));
            const { tmpSecretId, tmpSecretKey, tmpToken } = credential;
            return {
                secretId: tmpSecretId,
                secretKey: tmpSecretKey,
                token: tmpToken
            };
        }
    }
    // 无有效身份信息,提示登录
    logger.error('无有效身份信息,请使用 tcb login 登录');
    return {};
}
exports.getMetadata = getMetadata;
github mozilla / dxr / tooling / node / node_modules / lockdown / node_modules / npmconf / npmconf.js View on Github external
var data = target.data

  if (typeof data._password === 'string' &&
      typeof data.username === 'string') {
    var auth = data.username + ':' + data._password
    data = Object.keys(data).reduce(function (c, k) {
      if (k === 'username' || k === '_password')
        return c
      c[k] = data[k]
      return c
    }, { _auth: new Buffer(auth, 'utf8').toString('base64') })
    delete data.username
    delete data._password
  }

  data = ini.stringify(data)

  then = then.bind(this)
  done = done.bind(this)
  this._saving ++

  var mode = where === 'user' ? 0600 : 0666
  if (!data.trim()) {
    fs.unlink(target.path, function (er) {
      // ignore the possible error (e.g. the file doesn't exist)
      done(null)
    })
  } else {
    mkdirp(path.dirname(target.path), function (er) {
      if (er)
        return then(er)
      fs.writeFile(target.path, data, 'utf8', function (er) {
github geeklearningio / gl-vsts-tasks-yarn / Tasks / Yarn / npmrcparser.ts View on Github external
export function GetRegistries(npmrc: string): string[] {
    let registries: string[] = [];
    let config = ini.parse(fs.readFileSync(npmrc).toString());

    for (let key in config) {
        let colonIndex = key.indexOf(":");
        if (key.substring(colonIndex + 1).toLowerCase() === "registry") {
            config[key] = NormalizeRegistry(config[key]);
            registries.push(config[key]);
        }
    }

    // save the .npmrc with normalized registries
    tl.writeFile(npmrc, ini.stringify(config));
    return registries;
}
github nullivex / nodist / bin / node_modules / npm / lib / utils / ini.js View on Github external
encryptAuth(config, function () { // ignore errors
    var data = {}
    Object.keys(config).forEach(function (k) {
      data[k] = unParseField(config[k], k)
    })
    data = ini.stringify(data)
    return (data.trim())
         ? writeConfigfile(file, data, which, cb)
         : rimraf(file, cb)
  })
}
github graalvm / graaljs / test / simple / test-ini.js View on Github external
"[the section with whitespace]\n"+
                "this has whitespace = yep\n"+
                "just a flag, no value.\n"+
                "[section]\n"+
                "one = two\n"+
                "Foo = Bar\n"+
                "this = Your Mother!\n"+
                "blank = \n"+
                "[Section Two]\n"+
                "something else = blah\n"+
                "remove = whitespace\n";

  assert.deepEqual(iniContents, expect,
    "actual: \n"+inspect(iniContents) +"\n≠\nexpected:\n"+inspect(expect));

  assert.equal(ini.stringify(iniContents), expectStr,
    "actual: \n"+inspect(ini.stringify(iniContents)) +"\n≠\nexpected:\n"+inspect(expectStr));
});
github npm / npmconf / test / save.js View on Github external
npmconf.load(function (er, conf) {
    if (er)
      throw er
    conf.set('sign-git-tag', false, 'user')
    conf.del('nodedir')
    conf.del('tmp')
    var foundConf = ini.stringify(conf.sources.user.data)
    t.same(ini.parse(foundConf), ini.parse(expectConf))
    fs.unlinkSync(common.userconfig)
    conf.save('user', function (er) {
      if (er)
        throw er
      var uc = fs.readFileSync(conf.get('userconfig'), 'utf8')
      t.same(ini.parse(uc), ini.parse(expectFile))
      t.end()
    })
  })
})
github awslabs / amplify-video / provider-utils / awscloudformation / utils / livestream-obs.js View on Github external
async function generateINI(projectName, directory) {
  const iniBasic = ini.parse(fs.readFileSync(`${__dirname}/../obs-templates/basic.ini`, 'utf-8'));
  iniBasic.General.Name = projectName;
  fs.writeFileSync(`${directory}basic.ini`, ini.stringify(iniBasic));
}
github ehmicky / autoserver / src / formats / adapters / ini.js View on Github external
const serialize = function({ content }) {
  const contentA = fullRecurseMap(content, escapeEmptyArrays)
  return iniStringify(contentA)
}
github anther / smashladder-desktop / app / utils / DolphinConfigurationUpdater.js View on Github external
saveConfiguration(config) {
		return this.saveFile(ini.stringify(config, { whitespace: true }));
	}

ini

An ini encoder/decoder for node

ISC
Latest version published 2 months ago

Package Health Score

95 / 100
Full package analysis