@renoirb/tools-bundling-helpers
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

@renoirb/tools-bundling-helpers npm

Bundling helpers such as CLI utilities and packaging branding utilities

Size Dependencies
Bundle size Libraries.io dependency status for latest release

Usage

CommandLineUtilities

Utility we can use in a package's bin script.

#!/usr/bin/env node
'use strict';

const { CommandLineUtilities } = require('@renoirb/tools-bundling-helpers');

# Example of a way to handle logic by existence of a shell environment variable
const isCI = CommandLineUtilities.hasEnvFlag('CI_SERVER');
if (isCI) {
  process.argv.push('--quiet');
} else {
  process.argv.push('--verbose');
}

createBannerInfo

An utility to help manage a package's top of the file "banner"

// const pkg = require('../package.json')
// Imagine package.json had the lines like below
const pkg = {
  name: 'assimilate',
  version: '436.0.1',
  author: {
    email: '7.9@adjunct.3.unimatrix.1.borg',
    name: 'Seven Of Nine',
  },
}
const branding = {
  firstYear: 1484,
  vendor: 'Borg Collective',
}
const bannerInfo = createBannerInfo(pkg, branding)
console.log(bannerInfo)

Would return

{
  "author": "Seven Of Nine <7.9@adjunct.3.unimatrix.1.borg>",
  "copyright": "Copyright (c) 1484-2020 Borg Collective",
  "license": "LicenseRef-LICENSE",
  "name": "assimilate",
  "vendor": "Borg Collective",
  "version": "436.0.1"
}

We can pass this to createBannerFooter and get a banner and footer string for bundling tools such as Rollup.

// From example above
const bannerInfo = createBannerInfo(pkg, branding)
const bannerFooter = createBannerFooter(bannerInfo)
console.log(bannerFooter.banner)

Would return

/**
 * assimilate v436.0.1
 *
 * Maintainer: Seven Of Nine <7.9@adjunct.3.unimatrix.1.borg>
 *
 * LicenseRef-LICENSE
 *
 * © 1484-2020 Borg Collective
 */

Readme

Keywords

none

Package Sidebar

Install

npm i @renoirb/tools-bundling-helpers

Weekly Downloads

0

Version

1.2.1

License

MIT

Unpacked Size

15.9 kB

Total Files

18

Last publish

Collaborators

  • renoirb