Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function isPrerelease (version) {
la(is.unemptyString(version), 'expected version string', version)
// https://github.com/npm/node-semver#functions
const prereleaseComponents = semver.prerelease(version)
debug('version %s prerelease components %j', version, prereleaseComponents)
return is.array(prereleaseComponents) && is.not.empty(prereleaseComponents)
}
var compiled = require('compiled')
la(is.fn(compiled.build), 'missing build', compiled)
var packageFilename = path.join(process.cwd(), './package.json')
var pkg = JSON.parse(fs.readFileSync(packageFilename))
var config = pkg.config && pkg.config['pre-compiled']
la(is.object(config),
'missing pre-compiled config in package file', packageFilename)
// convert a string "files" value to an array
if (is.string(config.files)) {
config.files = [config.files]
}
// choose "dist" as default output directory
if (is.not.unemptyString(config.dir)) {
config.dir = 'dist'
}
la(is.all(config, {dir: is.unemptyString, files: is.array}),
'invalid compiled config', config)
var nodeFeatures = require('../features/get-features')()
la(is.object(nodeFeatures), 'could not load node features')
// assuming pre-compiled module will do the bundle copy on the client side
config.moduleWithBabelPolyfill = 'pick-precompiled'
compiled.build(config)
.then(function () {
var versions = is.array(config.versions) && config.versions ||
is.array(config.node) && config.node
it('handles just name', function () {
const s = split('foo')
la(is.object(s), s)
la(s.name === 'foo', 'name', s)
la(is.not.defined(s.version), 'version', s)
})
{
name: 'v1.0.0',
body: '<a>nice</a>\nfirst release\n\nsecond line\n'
},
{
name: 'v1.0.1',
body: 'little fix'
}
]
}
const human = toHuman(releases)
la(human.length === releases.versions.length, 'wrong number of versions')
checkOutput(human)
const notes = human[0].release
la(is.unemptyString(notes), 'missing notes', human)
la(is.not.found(notes.indexOf('nice')), 'did not remove html line', notes)
la(
is.not.found(notes.indexOf('second line')),
'did not remove second line',
notes
)
console.log(notes)
})
})
_recordAnswers (answers) {
la(is.unemptyString(answers.name), 'missing name', answers)
if (is.not.unemptyString(answers.description)) {
errors.onMissingDescription()
}
if (is.not.unemptyString(answers.keywords)) {
errors.onMissingKeywords()
}
answers.keywords = answers.keywords.split(',').filter(isEmpty)
this.answers = _.extend(defaults, answers)
la(
is.unemptyString(this.answers.name),
'missing full name',
this.answers.name
)
this.answers.noScopeName = withoutScope(this.answers.name)
la(
is.unemptyString(this.answers.noScopeName),
'could not compute name without scope from',
this.answers.name
)
const validateList = (schema, values) => {
if (is.not.array(values)) {
return {
valid: false,
message: 'expected an Array, got ' + typeof values
}
}
let msg
values.some(value => {
const result = validate(schema, value)
if (!result.valid) {
msg = 'item in the list does not pass the schema\n' +
formatErrors(result.errors) + '\n' + stringify(value)
return true
}
})
return {
valid: msg === undefined,
name: 'v1.0.0',
body: 'first release\n\nsecond line\n'
},
{
name: 'v1.0.1',
body: 'little fix'
}
]
}
const human = toHuman(releases)
la(human.length === releases.versions.length, 'wrong number of versions')
checkOutput(human)
const notes = human[0].release
la(is.unemptyString(notes), 'missing notes', human)
la(
is.not.found(notes.indexOf('second line')),
'did not remove second line',
notes
)
})
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})`
}
function isGithubName (str) {
if (check.not.unemptyString(str)) {
return false
}
var parsed = parseGh(str)
return check.array(parsed)
}
const pickFoundVersion = target => found => {
la(is.array(found), 'expected list of found items', found)
if (is.not.semver(target)) {
return latestVersion(found)
}
debug('need to pick version %s', target)
debug('from list with %d found items', found.length)
const sameVersion = R.propEq('version', target)
return R.find(sameVersion, found)
}