How to use expand-template - 1 common examples

To help you get started, we’ve selected a few expand-template 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 zeit / pkg-fetch / lib / places.js View on Github external
import { major, minor } from 'semver';
import expandTemplate from 'expand-template';
import os from 'os';
import path from 'path';
import placesJson from '../places.json';
const expand = expandTemplate();

const { PKG_CACHE_PATH } = process.env;
const cachePath = PKG_CACHE_PATH ||
  path.join(os.homedir(), '.pkg-cache');

function tagFromVersion (version) {
  const mj = major(version);
  const mn = minor(version);
  return `v${mj}.${mn}`;

export function localPlace (opts) {
  const p = placesJson.localPlace;
  const { version } = opts;
  const tag = tagFromVersion(version);
  Object.assign(opts, { tag });


Expand placeholders in a template string

Latest version published 4 years ago

Package Health Score

65 / 100
Full package analysis

Popular expand-template functions