How to use the check-more-types.fn 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 bahmutov / next-update / src / registry.js View on Github external
var la = require('lazy-ass')
var check = require('check-more-types')
var log = require('debug')('next-update')
const R = require('ramda')

var request = require('request')
var verify = check.verify
var semver = require('semver')
var q = require('q')
var localVersion = require('./local-module-version')
var isUrl = require('npm-utils').isUrl
var _ = require('lodash')
const {isPrerelease} = require('./utils')

var _registryUrl = require('npm-utils').registryUrl
la(check.fn(_registryUrl), 'expected registry url function')
var registryUrl = _.once(_registryUrl)

const notPrerelease = R.complement(isPrerelease)

function cleanVersion (version, name) {
  var originalVersion = version
  verify.unemptyString(version, 'missing version string' + version)
  verify.unemptyString(name, 'missing name string' + name)

  if (isUrl(version)) {
        // version = version.substr(version.indexOf('#') + 1);

        // hmm, because we don't have a way to fetch git tags yet
        // just skip these dependencies
    console.log('Cannot handle git repos, skipping', name, 'at', version)
    return
github bahmutov / copi / src / fake-registry.js View on Github external
function makeRegistry (find, options) {
  la(is.fn(find), 'missing find package function')

  const express = require('express')
  const morgan = require('morgan')
  const app = express()

  function getTarball (req, res) {
    console.log('tarball for %s@%s', req.params.name, req.params.version)

    const found = find(req.params.name)
    if (!found) {
      return res.status(404).send({})
    }

    // console.log('found package')
    // console.log(found)
github bahmutov / self-addressed / test / basic-spec.js View on Github external
it('is a single function', function () {
    la(check.fn(stamp));
  });
github bahmutov / generator-node-bahmutov / app / https-remote-git-url-spec.js View on Github external
it('is a function', () => {
    la(is.fn(gitRemoteToHttps))
  })
github bahmutov / pre-git / bin / commit-msg.js View on Github external
if (msgPattern) {
    checkMessageAgainstPattern(msg, msgPattern);
  }

  const wizard = preGit.wizard();
  if (!wizard) {
    log('no commit message wizard defined');
    process.exit(0);
  }

  log('found commit message wizard with name', wizard.name);

  la(check.fn(wizard.validate),
      'missing wizard validate method,', Object.keys(wizard));
  la(check.fn(preGit.printError),
      'missing preGit.printError,', Object.keys(preGit));

  log('checking commit message:', msg);
  const isValid = wizard.validate(msg);
  if (!isValid) {
    log('invalid commit message', msg);
    process.exit(-1);
  }
  log('valid git commit message');
}
github bahmutov / npm-utils / src / publish.js View on Github external
'use strict'

var la = require('lazy-ass')
var is = require('check-more-types')
var run = require('./npm-test')
var debug = require('debug')('npm-utils')
var q = require('q')

la(is.fn(run), 'expected function')

function publish (options) {
  options = options || {}
  var command = 'npm publish'
  if (is.unemptyString(options.tag)) {
    debug('publishing with a tag', options.tag)
    command += ' --tag ' + options.tag
  }

  if (is.unemptyString(options.access)) {
    debug('publishing with specific access', options.access)
    command += ' --access ' + options.access
  }

  return run(command)
    .catch(function (info) {
github bahmutov / pre-git / src / validate-commit-message.js View on Github external
function pickFunction(validator) {
  const isValid = check.fn(validator) ? validator : validator.validateMessage;
  la(check.fn(isValid), 'validator is not a function', isValid);
  return isValid;
}
github bahmutov / pre-git / bin / commit-wizard.js View on Github external
function isValidMessage(message) {
  if (!wizard) {
    return message;
  }

  la(check.unemptyString(message), 'missing message');

  const first = firstLine(message);

  if (!check.unemptyString(first)) {
    return Promise.reject(new Error('missing first line'));
  }
  if (check.fn(wizard.validate)) {
    if (!wizard.validate(message)) {
      return Promise.reject(new Error('Invalid commit message\n' + message));
    }
  }
  return message;
}