gatsby-core-utils
A collection of gatsby utils used in different gatsby packages
Last updated 5 years ago by pieh .
MIT · Repository · Bugs · Original npm
$ cnpm install gatsby-core-utils 
SYNC missed versions from official npm registry.

gatsby-core-utils

A list of utilities used in multiple gatsby packages.

Usage

npm install --save gatsby-core-utils

createContentDigest

Encrypts an input using md5 hash of hexadecimal digest.

const { createContentDigest } = require("gatsby-core-utils")

const options = {
  key: "value",
  foo: "bar",
}

const digest = createContentDigest(options)
// ...

cpuCoreCount

Calculate the number of CPU cores on the current machine

This function can be controlled by an env variable GATSBY_CPU_COUNT setting the first argument to true.

value description
Counts amount of real cores by running a shell command
logical-cores require("os").cpus() to count all virtual cores
any number Sets cpu count to that specific number
const { cpuCoreCount } = require("gatsby-core-utils")

const coreCount = cpuCoreCount(false)
// ...
const { cpuCoreCount } = require("gatsby-core-utils")
process.env.GATSBY_CPU_COUNT = "logical-cores"

const coreCount = cpuCoreCount()
// ...

joinPath

A utility that joins paths with a / on windows and unix-type platforms. This can also be used for URL concatenation.

const { joinPath } = require("gatsby-core-utils")

const BASEPATH = "/mybase/"
const pathname = "./gatsby/is/awesome"
const url = joinPath(BASEPATH, pathname)
// ...

isCI

A utility that enhances isCI from 'ci-info` with support for Vercel and Heroku detection

const { isCI } = require("gatsby-core-utils")

if (isCI()) {
  // execute CI-specific code
}
// ...

getCIName

A utility that returns the name of the current CI environment if available, null otherwise

const { getCIName } = require("gatsby-core-utils")

const CI_NAME = getCIName()
console.log({ CI_NAME })
// {CI_NAME: null}, or
// {CI_NAME: "ZEIT Now"}
// ...

createRequireFromPath

A cross-version polyfill for Node's Module.createRequire.

const { createRequireFromPath } = require("gatsby-core-utils")

const requireUtil = createRequireFromPath("../src/utils/")

// Require `../src/utils/some-tool`
requireUtil("./some-tool")
// ...

Current Tags

  • 1.0.27-berry-mdx.56                                ...           berry-mdx (6 years ago)
  • 1.3.5                                ...           latest (5 years ago)
  • 1.0.7-otp-test.69                                ...           otp-test (6 years ago)
  • 1.1.2-prompt-restart.146                                ...           prompt-restart (5 years ago)

90 Versions

  • 1.3.11                                ...           5 years ago
  • 1.3.21                                ...           5 years ago
  • 1.4.0-next.0                                ...           5 years ago
  • 1.3.20                                ...           5 years ago
  • 1.3.15                                ...           5 years ago
  • 1.3.12                                ...           5 years ago
  • 1.3.17                                ...           5 years ago
  • 1.10.0-next.0                                ...           5 years ago
  • 2.9.0-next.0                                ...           4 years ago
  • 1.3.14                                ...           5 years ago
  • 1.10.0                                ...           5 years ago
  • 1.3.8                                ...           5 years ago
  • 1.8.0-next.0                                ...           5 years ago
  • 1.9.0-next.0                                ...           5 years ago
  • 3.9.0-next.1                                ...           4 years ago
  • 3.12.0-next.2                                ...           3 years ago
  • 3.3.0-next.1                                ...           4 years ago
  • 3.3.0-next.0                                ...           4 years ago
  • 1.6.0-next.0                                ...           5 years ago
  • 2.14.0-next.2                                ...           4 years ago
  • 1.3.23                                ...           5 years ago
  • 2.13.0-next.0                                ...           4 years ago
  • 1.7.0-next.0                                ...           5 years ago
  • 2.0.0-next.0                                ...           5 years ago
  • 1.11.0-next.0                                ...           5 years ago
  • 3.7.0-next.0                                ...           4 years ago
  • 2.14.0                                ...           4 years ago
  • 3.10.0-next.2                                ...           3 years ago
  • 2.10.0-next.0                                ...           4 years ago
  • 2.7.0-next.0                                ...           4 years ago
  • 2.4.0-next.0                                ...           4 years ago
  • 3.0.0-zz-next.1                                ...           4 years ago
  • 3.7.0-next.1                                ...           4 years ago
  • 3.2.0-next.0                                ...           4 years ago
  • 3.9.0-next.0                                ...           4 years ago
  • 2.8.0-next.0                                ...           4 years ago
  • 2.6.0-next.0                                ...           4 years ago
  • 3.2.0-next.1                                ...           4 years ago
  • 2.1.0-next.1                                ...           5 years ago
  • 3.15.0-next.0                                ...           3 years ago
  • 3.15.0-next.1                                ...           3 years ago
  • 3.13.0-next.0                                ...           3 years ago
  • 3.8.0-next.0                                ...           4 years ago
  • 2.3.0-next.0                                ...           4 years ago
  • 2.2.0-next.0                                ...           4 years ago
  • 2.11.0-next.0                                ...           4 years ago
  • 2.0.0-v3rc.0                                ...           5 years ago
  • 1.1.3-unifiedroutes.76                                ...           5 years ago
  • 1.5.0-telemetry-test.360                                ...           5 years ago
  • 2.0.0-reach-router.13 [deprecated]           ...           5 years ago
  • 3.16.0-next.0                                ...           3 years ago
  • 3.15.0                                ...           3 years ago
  • 3.8.0-alpha-image-service.35                                ...           4 years ago
  • 1.5.0-image-helpers.58                                ...           5 years ago
  • 3.9.0-alpha-image-service2.14                                ...           4 years ago
  • 2.4.0-functions-next.18                                ...           4 years ago
  • 2.14.0-drupal-next.94                                ...           4 years ago
  • 2.12.0-coreutils.29                                ...           4 years ago
  • 3.6.0-alpha-ts-jit.27                                ...           4 years ago
  • 3.5.0-alpha-trailing-slash.71                                ...           4 years ago
  • 2.10.0-alpha-remote-file.48                                ...           4 years ago
  • 2.14.0-alpha-remote-fetch.79                                ...           4 years ago
  • 2.14.0-alpha-qe-sm.46                                ...           4 years ago
  • 3.0.0-alpha-9689ff.13                                ...           4 years ago
  • 1.10.1                                ...           5 years ago
  • 1.2.0                                ...           5 years ago
  • 1.0.22                                ...           6 years ago
  • 1.0.33                                ...           5 years ago
  • 1.3.4                                ...           5 years ago
  • 1.0.10                                ...           6 years ago
  • 1.0.13                                ...           6 years ago
  • 1.2.2                                ...           5 years ago
  • 1.2.1                                ...           5 years ago
  • 1.0.7                                ...           6 years ago
  • 1.0.26                                ...           6 years ago
  • 1.0.3                                ...           6 years ago
  • 1.0.27                                ...           6 years ago
  • 1.1.1                                ...           5 years ago
  • 1.3.3                                ...           5 years ago
  • 1.0.4                                ...           6 years ago
  • 1.1.4                                ...           5 years ago
  • 1.2.3                                ...           5 years ago
  • 1.0.14                                ...           6 years ago
  • 1.0.8                                ...           6 years ago
  • 1.0.28                                ...           6 years ago
  • 1.0.15                                ...           6 years ago
  • 1.1.2-prompt-restart.146                                ...           5 years ago
  • 1.0.7-otp-test.69                                ...           6 years ago
  • 1.0.27-berry-mdx.56                                ...           6 years ago
  • 1.3.5                                ...           5 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (6)
Dev Dependencies (6)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org