How to use the ini.decode 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 sidneys / ffmpeg-progressbar-cli / lib / main.js View on Github external
let onData = (data) => {
        if (!didStart) {
            // Bar::start()
            bar.start(totalTimeMs, {
                filename: formatter.filepathToFilename(filePath, BAR_FILENAME_LENGTH)
            })
            didStart = true
        }

        // Parse sparse output of nearly undocumented `-progress` argument 🤬🤬🤬
        // That is, key-value-pairs in .ini format
        const progressDictionary = ini.decode(data.toString())

        const currentTimeMicroseconds = Number(progressDictionary['out_time_ms'])
        const currentTimeMs = Math.round(currentTimeMicroseconds / 1000)

        // Bar::update() (noncritical errors are written to Bar.annotation)
        bar.update(currentTimeMs, null, !!lastError ? theme.warning(ellipsize(lastError, progressbarWidth + 7)) : null)

        // DEBUG
        // console.debug('progress (ms)', progressMilliseconds, 'duration (ms)', durationMilliseconds, 'fraction', (progressMilliseconds / durationMilliseconds))
    }
github dimitrov-adrian / RcloneTray / src / rclone.js View on Github external
}
    } else {
      // Sanitize booleans.
      if (optionDefinition.$Type === 'boolean') {
        if (optionDefinition.Name in values && ['true', 'yes', true, 1].indexOf(values[optionDefinition.Name]) > -1) {
          values[optionDefinition.Name] = 'true'
        } else {
          values[optionDefinition.Name] = 'false'
        }
      }
      valuesPlain[optionDefinition.Name] = values[optionDefinition.Name]
    }
  })

  try {
    let configIniStruct = ini.decode(fs.readFileSync(getConfigFile()).toString())
    configIniStruct[bookmarkName] = Object.assign(configIniStruct[bookmarkName], valuesPlain)
    fs.writeFileSync(getConfigFile(), ini.encode(configIniStruct, {
      whitespace: true
    }))
  } catch (err) {
    console.error(err)
    throw Error('Cannot update bookmark fields.')
  }
  console.log('Rclone', 'Updated bookmark', bookmarkName)
}
github hexparrot / mineos-node / test / test-mineos.js View on Github external
instance.previous_version('server.properties', '1B', function(err, file_contents) {
        var decoded = ini.decode(file_contents);
        test.equal(decoded['server-port'], 25565); 
        callback(err);
      })
    }
github npm / npm-profile / cmds / util / npmrc.js View on Github external
async function read (file) {
  try {
    return ini.decode(await readFile(file, 'utf8'))
  } catch (ex) {
    return {}
  }
}
github joelday / papyrus-lang / packages / papyrus-lang / src / config / CreationKitInisLoader.ts View on Github external
private parseIni(iniText: string) {
        return mapKeysDeep(iniParser.decode(iniText), (_v, k) =>
            k.toLowerCase()
        );
    }
}
github semantic-release / cli / src / lib / repository.js View on Github external
function getRemoteUrl({repository}) {
  if (!repository || !repository.url) {
    const gitConfig = ini.decode(readFileSync('./.git/config', 'utf8'));
    const repo = gitConfig['remote "origin"'].url;
    if (!repo) throw new Error('No repository found.');
    repository = {type: 'git', url: `${ghUrl(repo)}.git`};
  }

  const parsed = url.parse(repository.url);
  parsed.auth = null;
  parsed.protocol = 'https';
  repository.url = url.format(parsed);

  return repository.url;
}
github hyperdivision / hid / postinstall.js View on Github external
function buildUnix () {
  var lib = fs.realpathSync(path.join(__dirname, 'lib/libhidapi-hidraw-' + arch + '.so'))

  var la = ini.decode(fs.readFileSync(path.join(tmp, 'lib/libhidapi-hidraw.la')).toString())
  var dst = path.join(build, la.dlname)

  if (fs.existsSync(dst)) return
  copy(lib, dst, function (err) {
    if (err) throw err
  })
}
github sodium-friends / sodium-native / postinstall.js View on Github external
function buildUnix () {
  var lib = fs.realpathSync(path.join(__dirname, 'lib/libsodium-' + arch + '.so'))

  var la = ini.decode(fs.readFileSync(path.join(tmp, 'lib/libsodium.la')).toString())
  var dst = path.join(build, la.dlname)

  if (fs.existsSync(dst)) return
  copy(lib, dst, function (err) {
    if (err) throw err
  })
}

ini

An ini encoder/decoder for node

ISC
Latest version published 2 months ago

Package Health Score

95 / 100
Full package analysis