How to use true-myth - 5 common examples

To help you get started, we’ve selected a few true-myth 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 heroku / cli / packages / buildpacks / src / commands / buildpacks / versions.ts View on Github external
let registry: BuildpackRegistry
    let herokuAuth = this.heroku.auth || ''
    if (herokuAuth === '') {
      this.error('You need to be logged in to run this command.')
    }
    registry = new BuildpackRegistry()

    Result.match({
      Ok: _ => {},
      Err: err => {
        this.error(`Could not find the buildpack.\n${err}`)
      },
    }, BuildpackRegistry.isValidBuildpackSlug(args.buildpack))

    let result = await registry.listVersions(args.buildpack)
    Result.match({
      Ok: versions => {
        cli.table(versions.sort((a: RevisionBody, b: RevisionBody) => {
          return a.release > b.release ? -1 : 1
        }), {
          columns: [
            {key: 'release', label: 'Version'},
            {key: 'created_at', label: 'Released At'},
            {key: 'status', label: 'Status'}
          ]
        })
      },
      Err: err => {
        if (err.status === 404) {
          this.error(`Could not find '${args.buildpack}'`)
        } else {
          this.error(`Problem fetching versions, ${err.status}: ${err.description}`)
github heroku / cli / packages / buildpacks / src / commands / buildpacks / versions.ts View on Github external
async run() {
    let {args} = this.parse(Versions)
    let registry: BuildpackRegistry
    let herokuAuth = this.heroku.auth || ''
    if (herokuAuth === '') {
      this.error('You need to be logged in to run this command.')
    }
    registry = new BuildpackRegistry()

    Result.match({
      Ok: _ => {},
      Err: err => {
        this.error(`Could not find the buildpack.\n${err}`)
      },
    }, BuildpackRegistry.isValidBuildpackSlug(args.buildpack))

    let result = await registry.listVersions(args.buildpack)
    Result.match({
      Ok: versions => {
        cli.table(versions.sort((a: RevisionBody, b: RevisionBody) => {
          return a.release > b.release ? -1 : 1
        }), {
          columns: [
            {key: 'release', label: 'Version'},
            {key: 'created_at', label: 'Released At'},
            {key: 'status', label: 'Status'}
github heroku / cli / packages / buildpacks / src / commands / buildpacks / info.ts View on Github external
async run() {
    let {args} = this.parse(Info)
    let registry = new BuildpackRegistry()

    Result.match({
      Ok: _ => {},
      Err: err => {
        this.error(`Could not publish the buildpack.\n${err}`)
      },
    }, BuildpackRegistry.isValidBuildpackSlug(args.buildpack))

    let result = await registry.info(args.buildpack)
    Result.match({
      Ok: buildpack => {
        cli.styledHeader(args.buildpack)
        cli.styledObject(buildpack, ['description', 'category', 'license', 'support', 'source', 'readme'])
      },
      Err: err => {
        if (err.status === 404) {
          cli.error(`Could not find the buildpack '${args.buildpack}'`)
        } else {
github heroku / cli / packages / buildpacks / src / buildpacks.ts View on Github external
async registryNameToUrl(buildpack: string): Promise {
    if (validUrl.isWebUri(buildpack)) {
      return buildpack
    }

    Result.match({
      Ok: _ => {},
      Err: err => {
        cli.error(`Could not find the buildpack: ${buildpack}. ${err}`, {exit: 1})
      },
    }, BuildpackRegistry.isValidBuildpackSlug(buildpack))

    try {
      let response = await this.registry.buildpackExists(buildpack)
      let body = await response.json()
      return body.blob_url
    } catch (err) {
      if (err.statusCode === 404) {
        cli.error(`${buildpack} is not in the buildpack registry.`, {exit: 1})
      } else if (err.statusCode) {
        cli.error(`${err.statusCode}: ${err.message}`, {exit: 1})
      } else {
github heroku / cli / packages / buildpacks / src / commands / buildpacks / info.ts View on Github external
async run() {
    let {args} = this.parse(Info)
    let registry = new BuildpackRegistry()

    Result.match({
      Ok: _ => {},
      Err: err => {
        this.error(`Could not publish the buildpack.\n${err}`)
      },
    }, BuildpackRegistry.isValidBuildpackSlug(args.buildpack))

    let result = await registry.info(args.buildpack)
    Result.match({
      Ok: buildpack => {
        cli.styledHeader(args.buildpack)
        cli.styledObject(buildpack, ['description', 'category', 'license', 'support', 'source', 'readme'])
      },
      Err: err => {
        if (err.status === 404) {
          cli.error(`Could not find the buildpack '${args.buildpack}'`)
        } else {
          cli.error(`Problems finding buildpack info: ${err.description}`)
        }
      }
    }, result)
  }
}

true-myth

A library for safe functional programming in JavaScript, with first-class support for TypeScript

MIT
Latest version published 8 months ago

Package Health Score

82 / 100
Full package analysis

Popular true-myth functions