How to use the @instructure/command-utils.error function in @instructure/command-utils

To help you get started, we’ve selected a few @instructure/command-utils 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 instructure / instructure-ui / packages / ui-scripts / lib / deploy-docs.js View on Github external
function deployDocs (packageName, currentVersion, config = {}) {
  setupGit()

  if (isReleaseCommit(currentVersion)) {
    checkWorkingDirectory()
    info(`📖   Deploying documentation for ${currentVersion} of ${packageName}...`)
    try {
      publishGithubPages(config)
    } catch (err) {
      error(err)
      process.exit(1)
    }
    info(`📖   Documentation for ${currentVersion} of ${packageName} was successfully deployed!`)
  } else {
    info(`📦  Not on a release commit--skipping documentation publish.`)
  }
}
github instructure / instructure-ui / packages / ui-scripts / lib / publish.js View on Github external
checkIfGitTagExists(currentVersion)
    checkIfCommitIsReviewed()
    info(`📦  Currently on release commit for ${currentVersion} of ${packageName}.`)
    versionToRelease = currentVersion
    tag = preidAndTag || 'latest'
  } else {
    info(`📦  Not on a release commit--publishing a pre-release...`)
    versionToRelease = 'prerelease'
    tag = preidAndTag || 'rc'
  }

  let releasedVersion
  try {
    releasedVersion = await publishPackages(packageName, versionToRelease, tag)
  } catch (e) {
    error(e)
    process.exit(1)
  }

  if (GERRIT_CHANGE_NUMBER && GERRIT_PATCHSET_NUMBER) {
    try {
      await postGerritReview(
        `${GERRIT_CHANGE_NUMBER},${GERRIT_PATCHSET_NUMBER}`,
        `Successfully published ${releasedVersion} for this commit.`
      )
      process.exit(0)
    } catch (e) {
      error(e)
      process.exit(1)
    }
  }
}
github instructure / instructure-ui / packages / ui-scripts / lib / lint-commit.js View on Github external
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

const { error } = require('@instructure/command-utils')

const { lintCommitMessage } = require('./utils/git')

try {
  lintCommit()
} catch (err) {
  error(err)
  process.exit(1)
}

async function lintCommit () {
  const isValid = lintCommitMessage()

  if (isValid) {
    process.exit(0)
  } else {
    error('(See https://www.npmjs.com/package/conventional-changelog-angular)')
    process.exit(1)
  }
}
github instructure / instructure-ui / packages / ui-scripts / lib / utils / git.js View on Github external
exports.checkWorkingDirectory = function checkWorkingDirectory () {
  let result

  try {
    result = runGitCommand(['status', '--porcelain'])
  } catch (e) {
    error(e)
    process.exit(1)
  }

  if (result) {
    error(`Refusing to operate on unclean working directory!`)
    error(result)
    process.exit(1)
  }
}
github instructure / instructure-ui / packages / ui-scripts / lib / lint-commit.js View on Github external
async function lintCommit () {
  const isValid = lintCommitMessage()

  if (isValid) {
    process.exit(0)
  } else {
    error('(See https://www.npmjs.com/package/conventional-changelog-angular)')
    process.exit(1)
  }
}
github instructure / instructure-ui / packages / instui-cli / lib / handlers / handleExecuteCodemods.js View on Github external
const executeCodemods = ({ sourcePath, configPaths, codemodName, ignore }) => {
  try {
    const codemodPath = require.resolve(`@instructure/ui-codemods/lib/${codemodName}`)

    for (const configPath of configPaths) {
      executeCodemod({ sourcePath, codemodPath, configPath, ignore })
    }
  } catch (err) {
    error(err)
    process.exit(1)
  }
}
github instructure / instructure-ui / packages / ui-scripts / lib / tag.js View on Github external
return Promise.all(getPackages().map(async pkg => {
    if (pkg.private) {
      info(`${pkg.name} is private.`)
    } else {
      const toTag = `${pkg.name}@${versionToTag}`
      info(`📦  Running 'dist-tag ${command} ${toTag} ${tag}'...`)
      try {
        await runCommandAsync('npm', ['dist-tag', command, toTag, tag])
      } catch (err) {
        error(err)
      }
      info(`📦  ${toTag} tags were successfully updated!`)
    }
  }))
}
github instructure / instructure-ui / packages / ui-scripts / lib / utils / gerrit.js View on Github external
gerritClient().review(target, { message, labels }, (err) => {
      if (err) {
        error(`An error occured posting a gerrit review for ${target}.`)
        error(err)
        reject(err)
      }
      resolve()
    })
  })
github instructure / instructure-ui / packages / ui-scripts / lib / utils / slack.js View on Github external
'text': message + issues,
      'link_names': 1
    }

    const req = https.request({
      path: `/services/${SLACK_WEBHOOK}`,
      hostname: 'hooks.slack.com',
      method: 'POST'
    })

    req.write(JSON.stringify(payload))
    req.end()

    info(`💬  Posted Slack Message: "${message + issues}"`)
  } else if (config.slack_channel && !SLACK_WEBHOOK) {
    error(`'SLACK_WEBHOOK' env variable isn't set for ${config.slack_channel}!`)
  }
}

@instructure/command-utils

Node CLI utilities made by Instructure Inc.

MIT
Latest version published 2 days ago

Package Health Score

84 / 100
Full package analysis

Similar packages