Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function errorHandler (er) {
log.disableProgress()
if (!npm.config || !npm.config.loaded) {
// logging won't work unless we pretend that it's ready
er = er || new Error('Exit prior to config file resolving.')
console.error(er.stack || er.message)
}
if (cbCalled) {
er = er || new Error('Callback called more than once.')
}
cbCalled = true
if (!er) return exit(0)
if (typeof er === 'string') {
log.error('', er)
return exit(1, true)
} else if (!(er instanceof Error)) {
}
if (msgJson.length === 1) {
msg = JSON.stringify(msgJson[0], null, 2) + '\n'
} else if (msgJson.length > 1) {
msg = JSON.stringify(msgJson, null, 2) + '\n'
}
}
// preserve output symmetry by adding a whitespace-only line at the end if
// there's one at the beginning
if (/^\s*\n/.test(msg)) msg += '\n'
// disable the progress bar entirely, as we can't meaningfully update it if
// we may have partial lines printed.
log.disableProgress()
// print directly to stdout to not unnecessarily add blank lines
process.stdout.write(msg, () => cb(null, data))
}
function cleanup (data) {
return cb(new Error(
'You must compile node with ssl support to use the adduser feature'
))
}
let registry = npm.config.get('registry')
const scope = npm.config.get('scope')
const creds = npm.config.getCredentialsByURI(npm.config.get('registry'))
if (scope) {
const scopedRegistry = npm.config.get(scope + ':registry')
const cliRegistry = npm.config.get('registry', 'cli')
if (scopedRegistry && !cliRegistry) registry = scopedRegistry
}
log.disableProgress()
let auth
try {
auth = require('./auth/' + npm.config.get('auth-type'))
} catch (e) {
return cb(new Error('no such auth module'))
}
auth.login(creds, registry, scope, function (err, newCreds) {
if (err) return cb(err)
npm.config.del('_token', 'user') // prevent legacy pollution
if (scope) npm.config.set(scope + ':registry', registry, 'user')
npm.config.setCredentialsByURI(registry, newCreds)
npm.config.save('user', cb)
})
}
.then((albums) => {
log.disableProgress()
console.log(makePlaylist([...albums].sort(byDate)))
})
}
function report (roots) {
log.disableProgress()
for (let [root, artists] of roots) {
const sorted = [...artists.values()].sort(bySize)
if (sorted.length) {
console.log('\nROOT %s:', root)
for (let a of sorted) {
console.log('%s [%sM]', a.name, a.getSize(1024 * 1024))
}
}
}
}
}).catch((e) => {
log.disableProgress()
log.error('packard', e.stack)
})
process.on('exit', () => {
log.disableProgress()
})
const successCallback = function successCallback () {
.then((albums) => {
log.disableProgress()
calculate([...albums], blockSize, capacity)
})
}
.then((albums) => {
log.disableProgress()
log.silly('audit', 'albums', albums)
for (let album of albums) {
const id = album.artist.name + ': ' + album.name + ' /'
for (let warning of auditAlbum(album)) log.warn('audit', id, warning)
}
})
}
const sorted = scanAlbums(roots, progressGroups).then((albums) => {
log.silly('scanAlbums', 'albums', albums)
const sorted = [...albums].sort(byDate)
log.silly('scanAlbums', 'sorted', sorted.map((a) => '[' + a.date + '] ' + a.name))
log.disableProgress()
return sorted
})