Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(function (data) {
la(check.array(data), 'could not get data for NPM package', name, data);
var packageInfo = data[0];
if (check.has(packageInfo, 'github')) {
// console.log(packageInfo);
githubRepos.push(packageToGithub(packageInfo));
}
});
});
it('finds node version option', () => {
const args = ['--node', '4', 'npm', 'version']
const options = findOptions(args).options
la(is.not.empty(options),
'found options', options, 'in', args)
la(is.has(options, 'node'), 'has node option', options)
// list of versions
la(is.array(options.node) &&
options.node.length === 1, 'single version', options)
la(options.node[0] === '4', 'found node 4', options)
})
function install (options, db) {
la(is.object(options), 'missing options', options)
la(is.unemptyString(options.name), 'missing name', options)
la(is.has(db, 'find'), 'missing find method in db')
const found = db.find(options.name)
if (!found || !found.latest) {
console.error('Could not find locally installed "%s", using NPM to install', options.name)
return npm.install({
name: options.name,
flags: options.flags
})
}
console.log('found %s@%s among %d candidate(s)',
options.name, found.latest, found.candidates.length)
debug(found)
la(is.unemptyString(found.folder), 'missing founder in found object', found)
it('parses example .git', function () {
var url = 'https://github.com/bahmutov/next-update.git'
var info = parse(url)
la(check.object(info), 'not an object', info)
la(check.has(info, 'user'), 'missing user', info)
la(check.has(info, 'repo'), 'missing repo', info)
la(info.user === 'bahmutov', 'wrong user', info)
la(info.repo === 'next-update', 'wrong repo', info)
})
it('parses example .git', function () {
var url = 'https://github.com/bahmutov/next-update.git'
var info = parse(url)
la(check.object(info), 'not an object', info)
la(check.has(info, 'user'), 'missing user', info)
la(check.has(info, 'repo'), 'missing repo', info)
la(info.user === 'bahmutov', 'wrong user', info)
la(info.repo === 'next-update', 'wrong repo', info)
})
function shouldFreeWhenDone(options) {
la(check.object(options), 'missing options object', options);
return ((check.has(options, 'keep') && !options.keep) ||
(check.has(options, 'cache') && !options.cache));
}
function isMultiTask(options) {
return check.object(options) &&
check.unemptyString(options.target) &&
check.has(options, 'src') &&
check.has(options, 'dest') &&
check.maybe.object(options.config);
}
function loadData (maxAge, filename) {
la(is.unemptyString(filename), 'missing filename', filename)
if (!fs.existsSync(filename)) {
return null
}
const text = fs.readFileSync(filename, 'utf-8')
const withTimestamp = JSON.parse(text)
la(is.has(withTimestamp, 'timestamp'), 'missing timestamp', Object.keys(withTimestamp))
const now = new Date()
const elapsed = now - new Date(withTimestamp.timestamp)
debug('cache age', elapsed, 'ms, maxAge', maxAge)
if (elapsed > maxAge) {
return null
}
la(is.has(withTimestamp, 'data'), 'missing data', Object.keys(withTimestamp))
return withTimestamp.data
}
function shouldFreeWhenDone(options) {
la(check.object(options), 'missing options object', options);
return ((check.has(options, 'keep') && !options.keep) ||
(check.has(options, 'cache') && !options.cache));
}