nuxt-html-inject-commands
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

nuxt-html-inject-commands

npm version npm downloads bundle size codecov license

Inject commands result into index.html meta tag.

Installation

# ✨ Auto-detect
npx nypm install -D nuxt-html-inject-commands

# npm
npm install -D nuxt-html-inject-commands

# yarn
yarn add -D nuxt-html-inject-commands

# pnpm
pnpm install -D nuxt-html-inject-commands

# bun
bun install -D nuxt-html-inject-commands

# deno
deno install --dev nuxt-html-inject-commands

Usage

// vite.config.ts
export default defineNuxtConfig({
  modules: ['nuxt-html-inject-commands'],
  htmlInjectCommands: {
    commands: [
      {
        name: 'git:commit',
        command: 'git log -1 --format="hash=%h, date=%aI"',
        errorMsg: 'Failed to get git commit hash',
      },
      {
        name: 'error:withmsg',
        command: 'exit 1',
        errorMsg: 'Failed to execute error command',
      },
      {
        name: 'error:withoutmsg',
        command: 'exit 1',
      },
    ],
  },
})

Type Declarations

export interface Options {
  /**
   * List of commands to be executed
   */
  commands: Command[]
}

export interface Command {
  /**
   * Which will be used to name attribute of the meta tag
   */
  name: string
  /**
   * Command to be executed
   * The result of the command will be injected into content attribute of the meta tag
   */
  command: string
  /**
   * Replease the content of the meta tag when the command fails
   */
  errorMsg?: string
}

Contribution

Local development
  • Clone this repository
  • Install the latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run tests using pnpm dev or pnpm test

License

Published under the MIT license. Made by @byronogis and community 💛


🤖 auto updated with automd (last updated: Mon Dec 30 2024)

Package Sidebar

Install

npm i nuxt-html-inject-commands

Weekly Downloads

2

Version

0.1.3

License

MIT

Unpacked Size

10.8 kB

Total Files

15

Last publish

Collaborators

  • byronogis