Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function isWhiteSpaceBefore (from, comment) {
const region = source.substr(from, comment.start - from)
if (is.empty(region)) {
return true
}
// console.log(`region "${region}" from ${from} comment starts ${comment.start}`)
const maybe = isWhiteSpace(region)
// console.log(`region "${region}" test ${maybe}`)
return maybe
}
function makeSureValidModule (moduleNames, checkingModules) {
la(check.maybe.array(moduleNames), 'expected list of modules', moduleNames)
la(check.array(checkingModules), 'expected list of modules to check', checkingModules)
if (isSingleItem(moduleNames) && check.empty(checkingModules)) {
console.error('Could not find module "%s" in the list of dependencies', moduleNames[0])
console.error('Please check the name')
process.exit(-1)
}
}
function npmInstall (list, options) {
la(is.array(list), 'expected list of modules to npm install', list)
la(is.strings(options), 'expected list of CLI options', options)
if (is.empty(list)) {
return Promise.resolve()
}
const flags = options.join(' ')
const names = list.map(fullInstallName).join(' ')
const cmd = `npm install ${flags} ${names}`
console.log(cmd)
return execa.shell(cmd)
}
function dontBreakDependents (options, dependents) {
if (check.arrayOf(check.object, dependents) || check.arrayOfStrings(dependents)) {
dependents = {
projects: dependents
}
}
la(check.arrayOf(function (item) {
return check.object(item) || check.string(item)
}, dependents.projects), 'invalid dependents', dependents.projects)
debug('dependents', dependents)
if (check.empty(dependents)) {
return Promise.resolve()
}
banner(' testing the following dependents\n ' + JSON.stringify(dependents))
var logSuccess = function logSuccess () {
console.log('all dependents tested')
}
return testDependents(options, dependents)
.then(logSuccess)
}
const pruneSnapshotsInFile = ({ fs, byFilename, ext }, opts) => file => {
const snapshots = fs.loadSnapshots(file, ext, {
useRelativePath: opts.useRelativePath || false
})
if (is.empty(snapshots)) {
debug('empty snapshots to prune in file', file)
return
}
const runtimeSnapshots = byFilename[file]
debug('run time snapshots by file')
debug(runtimeSnapshots)
const prunedSnapshots = pruneSnapshotsInObject(runtimeSnapshots, snapshots)
if (R.equals(prunedSnapshots, snapshots)) {
debug('nothing to prune for file', file)
return
}
debug('saving pruned snapshot file for', file)
function findOptions (args) {
la(is.array(args), 'expected list of arguments', args)
const options = {}
const result = {
options: options,
args: args
}
if (is.empty(args)) {
return result
}
if (!isOption(args[0])) {
return result
}
if (!isKnownOption(args[0])) {
debug('unknown option', args[0])
return result
}
debug('has option', args[0])
const normalName = normalizeOptionName(args[0])
const normalValue = normalizeOption(args[1])
debug('normalized', normalName, '=', normalValue)
function deriveRange (output) {
if (is.not.array(output)) {
return
}
if (is.empty(output)) {
return
}
if (!output.every(is.number)) {
return
}
const first = output[0]
const last = R.last(output)
la(is.number(last), 'invalid last element in list', output)
const after = last + 1
return {
f: R.always(R.range(first, after)),
name: `R.range(${first}, ${after})`
}
}