How to use lazy-ass - 10 common examples

To help you get started, we’ve selected a few lazy-ass 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 / binary / move-binaries.ts View on Github external
const s3 = s3helpers.makeS3(aws)

  // found s3 paths with last build for same commit for all platforms
  const lastBuilds: Desktop[] = []

  let platforms: platformArch[] = uploadUtils.getValidPlatformArchs()
  if (options['--platformArch']) {
    const onlyPlatform = options['--platformArch']
    console.log('only moving single platform %s', onlyPlatform)
    la(uploadUtils.isValidPlatformArch(onlyPlatform), 'invalid platform-arch', onlyPlatform)
    platforms = platforms.filter(equals(onlyPlatform))
  }
  la(platforms.length, 'no platforms to move', platforms)

  for (const platformArch of platforms) {
    la(uploadUtils.isValidPlatformArch(platformArch),
      'invalid platform arch', platformArch)

    const uploadDir = getUploadDirForPlatform({
      version: releaseOptions.version
    }, platformArch)
    console.log('finding binary for %s in %s', platformArch, uploadDir)

    const list: string[] = await s3helpers.listS3Objects(uploadDir, aws.bucket, s3)

    if (debug.enabled) {
      console.log('all found subfolders')
      console.log(list.join('\n'))
    }

    const lastBuildPath = findBuildByCommit(releaseOptions.commit, list)
    if (!lastBuildPath) {
github cypress-io / cypress / scripts / binary / move-binaries.ts View on Github external
'--commit': String,
    '--version': String,
    // optional, if passed, only the binary for that platform will be moved
    '--platformArch': String,
    // aliases
    '--sha': '--commit',
    '-v': '--version'
  }, {
    argv: args.slice(2)
  })
  debug('moveBinaries with options %o', options)

  // @ts-ignore
  la(is.commitId(options['--commit']), 'missing or invalid commit SHA', options)
  // @ts-ignore
  la(is.semver(options['--version']), 'missing version to collect', options)

  const releaseOptions: ReleaseInformation = {
    commit: options['--commit'],
    version: options['--version']
  }

  const aws = uploadUtils.getS3Credentials()
  const s3 = s3helpers.makeS3(aws)

  // found s3 paths with last build for same commit for all platforms
  const lastBuilds: Desktop[] = []

  let platforms: platformArch[] = uploadUtils.getValidPlatformArchs()
  if (options['--platformArch']) {
    const onlyPlatform = options['--platformArch']
    console.log('only moving single platform %s', onlyPlatform)
github cypress-io / cypress / scripts / binary / move-binaries.ts View on Github external
}

  const aws = uploadUtils.getS3Credentials()
  const s3 = s3helpers.makeS3(aws)

  // found s3 paths with last build for same commit for all platforms
  const lastBuilds: Desktop[] = []

  let platforms: platformArch[] = uploadUtils.getValidPlatformArchs()
  if (options['--platformArch']) {
    const onlyPlatform = options['--platformArch']
    console.log('only moving single platform %s', onlyPlatform)
    la(uploadUtils.isValidPlatformArch(onlyPlatform), 'invalid platform-arch', onlyPlatform)
    platforms = platforms.filter(equals(onlyPlatform))
  }
  la(platforms.length, 'no platforms to move', platforms)

  for (const platformArch of platforms) {
    la(uploadUtils.isValidPlatformArch(platformArch),
      'invalid platform arch', platformArch)

    const uploadDir = getUploadDirForPlatform({
      version: releaseOptions.version
    }, platformArch)
    console.log('finding binary for %s in %s', platformArch, uploadDir)

    const list: string[] = await s3helpers.listS3Objects(uploadDir, aws.bucket, s3)

    if (debug.enabled) {
      console.log('all found subfolders')
      console.log(list.join('\n'))
    }
github cypress-io / cypress / scripts / binary / move-binaries.ts View on Github external
const releaseOptions: ReleaseInformation = {
    commit: options['--commit'],
    version: options['--version']
  }

  const aws = uploadUtils.getS3Credentials()
  const s3 = s3helpers.makeS3(aws)

  // found s3 paths with last build for same commit for all platforms
  const lastBuilds: Desktop[] = []

  let platforms: platformArch[] = uploadUtils.getValidPlatformArchs()
  if (options['--platformArch']) {
    const onlyPlatform = options['--platformArch']
    console.log('only moving single platform %s', onlyPlatform)
    la(uploadUtils.isValidPlatformArch(onlyPlatform), 'invalid platform-arch', onlyPlatform)
    platforms = platforms.filter(equals(onlyPlatform))
  }
  la(platforms.length, 'no platforms to move', platforms)

  for (const platformArch of platforms) {
    la(uploadUtils.isValidPlatformArch(platformArch),
      'invalid platform arch', platformArch)

    const uploadDir = getUploadDirForPlatform({
      version: releaseOptions.version
    }, platformArch)
    console.log('finding binary for %s in %s', platformArch, uploadDir)

    const list: string[] = await s3helpers.listS3Objects(uploadDir, aws.bucket, s3)

    if (debug.enabled) {
github cypress-io / cypress / scripts / binary / move-binaries.ts View on Github external
debug('moveBinaries with args %o', args)
  const options = arg({
    '--commit': String,
    '--version': String,
    // optional, if passed, only the binary for that platform will be moved
    '--platformArch': String,
    // aliases
    '--sha': '--commit',
    '-v': '--version'
  }, {
    argv: args.slice(2)
  })
  debug('moveBinaries with options %o', options)

  // @ts-ignore
  la(is.commitId(options['--commit']), 'missing or invalid commit SHA', options)
  // @ts-ignore
  la(is.semver(options['--version']), 'missing version to collect', options)

  const releaseOptions: ReleaseInformation = {
    commit: options['--commit'],
    version: options['--version']
  }

  const aws = uploadUtils.getS3Credentials()
  const s3 = s3helpers.makeS3(aws)

  // found s3 paths with last build for same commit for all platforms
  const lastBuilds: Desktop[] = []

  let platforms: platformArch[] = uploadUtils.getValidPlatformArchs()
  if (options['--platformArch']) {
github bahmutov / rambo / tests / same.js View on Github external
const same = function (a, b) {
  const info = Array.from(arguments).slice(2)
  la.apply(null, [R.equals(a, b)].concat(info))
}
github cypress-io / cypress / scripts / binary / s3-api.ts View on Github external
listS3Objects (uploadDir: string, bucket: string, s3: S3): Promise {
    la(is.unemptyString(uploadDir), 'invalid upload dir', uploadDir)

    return new Promise((resolve, reject) => {
      const prefix = uploadDir + '/'
      s3.listObjectsV2({
        Bucket: bucket,
        Prefix: prefix,
        Delimiter: '/'
      }, (err, result) => {
        if (err) {
          return reject(err)
        }

        debug('AWS result in %s %s', bucket, prefix)
        debug('%o', result)

        resolve(result.CommonPrefixes.map(prop('Prefix')))
github cypress-io / cypress / scripts / binary / s3-api.ts View on Github external
makeS3 (aws) {
    la(is.unemptyString(aws.key), 'missing aws key')
    la(is.unemptyString(aws.secret), 'missing aws secret')

    return new S3({
      accessKeyId: aws.key,
      secretAccessKey: aws.secret
    })
  },
github cypress-io / cypress / scripts / binary / s3-api.ts View on Github external
setUserMetadata (bucket: string, key: string, metadata: S3.Metadata,
    contentType: S3.ContentType, acl: S3.ObjectCannedACL, s3: S3): Promise {
    la(hasOnlyStringValues(metadata),
      'metadata object can only have string values', metadata)

    return new Promise((resolve, reject) => {
      debug('setting metadata to %o for %s %s', metadata, bucket, key)

      const params: S3.CopyObjectRequest = {
        Bucket: bucket,
        CopySource: bucket + '/' + key,
        Key: key,
        Metadata: metadata,
        MetadataDirective: 'REPLACE',
        ContentType: contentType,
        ACL: acl
      }
      s3.copyObject(params, (err, data) => {
        if (err) {
github cypress-io / cypress / scripts / binary / s3-api.ts View on Github external
makeS3 (aws) {
    la(is.unemptyString(aws.key), 'missing aws key')
    la(is.unemptyString(aws.secret), 'missing aws secret')

    return new S3({
      accessKeyId: aws.key,
      secretAccessKey: aws.secret
    })
  },

lazy-ass

Lazy assertions without performance penalty

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis

Popular lazy-ass functions