How to use the check-more-types.object function in check-more-types

To help you get started, we’ve selected a few check-more-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cypress-io / cypress / scripts / add-install-comment.js View on Github external
getCIName,
  getCIBuildUrl,
} = require('./utils')
const { addCommitComment } = require('@cypress/github-commit-status-check')
const { stripIndent } = require('common-tags')

/* eslint-disable no-console */

const { npm, binary } = getNameAndBinary(process.argv)

la(is.unemptyString(npm), 'missing npm url')
la(is.unemptyString(binary), 'missing binary url')

const commitInfo = getShortCommit()

la(is.object(commitInfo), 'could not determine current commit information')
const { sha } = commitInfo

la(is.commitId(sha), 'could not find commit SHA')

const platform = os.platform()
const arch = os.arch()

console.log('posting pre-release instructions')
console.log(' commit:', sha)
console.log(' npm:', npm)
console.log(' binary:', binary)
console.log(' platform:', platform)
console.log(' arch:', arch)

const ciName = getCIName() || 'Unknown CI'
const buildUrl = getCIBuildUrl()
github bahmutov / pre-compiled / bin / precompile.js View on Github external
#!/usr/bin/env node

'use strict'

var la = require('lazy-ass')
var is = require('check-more-types')
var path = require('path')
var fs = require('fs')

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')()
github bahmutov / was-tested / src / dispatch.js View on Github external
function configDispatch (options, coverageOptions) {
  la(check.object(options), 'missing options', options)
  la(check.object(options.proxy), 'missing proxy', options)

  la(check.object(coverageOptions), 'missing coverage options')
  la(check.unemptyString(coverageOptions.savedReportDir), 'missing saved report dir', coverageOptions)

  var cover = require('./coverage')(coverageOptions)

  var reportServer = ecstatic({
    root: coverageOptions.savedReportDir,
    baseDir: getReportUrlPrefix + '/'
  })

  function isGetReportRequest (url) {
    var urlRegexp = new RegExp('^/' + getReportUrlPrefix + '/?')
    return urlRegexp.test(url)
  }
github bahmutov / now-pipeline / src / run-command.js View on Github external
function runCommand (command, extraEnv) {
  if (is.string(command)) {
    command = command.split(' ')
  }
  la(is.array(command), 'expected command and args array', command)
  la(command.length > 0, 'missing command, needs at least something', command)
  la(is.object(extraEnv), 'expected env object', extraEnv)

  return new Promise(function (resolve, reject) {
    const customEnv = Object.assign({}, process.env, extraEnv)

    const spawnOptions = {
      env: customEnv,
      stdio: 'inherit'
    }
    const prog = command[0]
    const args = command.slice(1)
    console.log(`running "${prog}" with extra env keys`,
      Object.keys(extraEnv))

    const proc = spawn(prog, args, spawnOptions)

    proc.on('error', (err) => {
github bahmutov / available-versions / src / available.js View on Github external
var result = {}

    try {
      var info = JSON.parse(body)
      if (info.error) {
        var str = 'ERROR in npm info for ' + name + ' reason ' + (info.reason || body)
        console.error(str)
        deferred.reject(new Error(str))
        return
      }
      debug('attaching repo information')
      attachRepoInformation(result, info)

      var versionObject = info.versions || info.time
      la(check.object(versionObject), 'could not find versions in', info)

      var versions = Object.keys(versionObject)
      if (!Array.isArray(versions)) {
        throw new Error('Could not get versions for ' + name + ' from ' + info)
      }

      var validVersions = versions.filter(function (ver) {
        return cleanVersion(ver, name, silent)
      })

      if (query.version) {
        debug('have query version')
        la(check.string(query.version), 'missing version string, have', query.version)
        validVersions = validVersions.filter(function (ver) {
          var later = semver.gt(ver, query.version)
          return later
github cypress-io / snapshot / src / snapshot-spec.js View on Github external
it('is an object', () => {
    la(is.object(api))
  })
github bahmutov / compiled / src / utils.js View on Github external
function formFilenames (config, filename) {
  la(is.object(config), 'missing config object', config)
  la(is.unemptyString(filename), 'expected filename', filename)

  var joinDir = join.bind(null, config.dir)

  var name = bundleName(filename)
  var builtFilename = joinDir(builtName(name))
  var featuresFilename = joinDir(featuresName(name))

  var compiledFilename = is.fn(config.formOutputFilename)
    ? config.formOutputFilename(name)
    : joinDir(compiledName(name))

  return {
    built: builtFilename,
    features: featuresFilename,
    compiled: compiledFilename
github bahmutov / next-update / src / next-update.js View on Github external
function isSingleSpecificVersion (moduleNames) {
  if (!moduleNames) {
    return false
  }
  var name = moduleNames
  if (Array.isArray(moduleNames)) {
    if (moduleNames.length !== 1) {
      return false
    }
    name = moduleNames[0]
  }
  check.verify.string(name, 'expected module name string, not ' +
        JSON.stringify(name))
  var parsed = nameVersionParser(name)
  if (check.object(parsed)) {
    return false
  }
  return check.string(parsed.version)
}
github bahmutov / todomvc-express / src / app.js View on Github external
function hasMethodField (req) {
  return is.object(req.body) && is.unemptyString(req.body._method)
}
github bahmutov / changed-log / src / changed-log.js View on Github external
function findCommentsBetweenTags (options) {
  la(check.object(options), 'missing options', options)
  la(check.object(options.fromTag), 'missing fromTag', options)
  la(check.object(options.toTag), 'missing toTag', options)

  var findCommits = require('./get-comments-between-commits')
  var findOptions = {
    user: options.user,
    repo: options.repo,
    from: options.fromTag.sha,
    to: options.toTag.sha
  }

  function setReport (report) {
    report.options.name = options.name
    report.options.from = options.from
    report.options.to = options.to
    return report