Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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))
}
}
} 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)
}
instance.previous_version('server.properties', '1B', function(err, file_contents) {
var decoded = ini.decode(file_contents);
test.equal(decoded['server-port'], 25565);
callback(err);
})
}
async function read (file) {
try {
return ini.decode(await readFile(file, 'utf8'))
} catch (ex) {
return {}
}
}
private parseIni(iniText: string) {
return mapKeysDeep(iniParser.decode(iniText), (_v, k) =>
k.toLowerCase()
);
}
}
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;
}
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
})
}
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
})
}