npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

preamble-cli

v2.0.0

Published

A CLI tool that prepends text and/or file data to an output file.

Downloads

24

Readme

Preamble CLI

A CLI tool that prepends text and/or file data to an output file.

Usage

npm i preamble-cli -D

npm

preamble [<options>...] -o <file>

Options

  --help, -h
    Displays help information about this script
    'preamble -h' or 'preamble --help'

  --print, -p
    Text to prepend to your output file.
    This content is added BEFORE the text from the --external and --more options.
    'preamble --print=<string>' or 'preamble -p <string>'

  --external, -e
    A file that has text to be used as prepend data for your output file.
    This content is added IN-BETWEEN the text from the --print and --more options.
    'preamble --external=<file-path>' or 'preamble -e <file-path>'

  --more, -m
    Additional text to prepend to your output file.
    This content is added AFTER the text from the --print and --external options.
    'preamble --more=<string>' or 'preamble -m <string>'

  --output, -o
    The file to prepend your text to. The output is encoded as UTF-8.
    'preamble --output=<file-path>' or 'preamble -o <file-path>'

Prepend Order

This tool has three ways to prepend content. You can use any one of them, or all three. The output order is as follows:

  1. --print
  2. --external
  3. --more

Having three options allows you do things like add contents from a file as commented text. See the LICENSE sample below.

Samples

Prepend text to a file.

preamble -p "/*Released under the MIT License*/\n" -o ./dist/script.min.js

Prepend content from a file.

preamble -e ./prepend.txt -o ./dist/script.min.js

Add content from a LICENSE file as commented text.

preamble -p "/*" -e ./LICENSE.md -m "*/" -o ./dist/script.min.js

Special Character Support

Newlines (\n) and tabs (\t) are supported. If you need to output either character-set as text, double escape them.

+=====================================================+
| Command                              | Output       |
|=====================================================|
| preamble -o test.txt -p "\n"         | newline      |
|--------------------------------------+--------------|
| preamble -o test.txt -p "\\n"        | newline      |
|--------------------------------------+--------------|
| preamble -o test.txt -p "\\\n"       | \n           |
|--------------------------------------+--------------|
| preamble -o test.txt -p "\\\\n"      | \n           |
|--------------------------------------+--------------|
| preamble -o test.txt -p \n           | n            |
|--------------------------------------+--------------|
| preamble -o test.txt -p \\n          | newline      |
|--------------------------------------+--------------|
| preamble -o test.txt -p \\\n         | newline      |
|--------------------------------------+--------------|
| preamble -o test.txt -p \\\\n        | \n           |
+=====================================================+

Dependencies

License

Copyright (c) 2017 Leandro Silva (http://grafluxe.com)

Released under the MIT License.

See LICENSE.md for entire terms.