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

partpipe

v1.0.0

Published

Command line filter to apply unix filter to parts of input stream.

Downloads

4

Readme

partpipe - embedding version/date/any data to template text/source.

A command line tool,like C-preprocessor/sed/awk/perl.for embedding version/date/any data to template text/source.

Like #ifdef, you can enable/disable parts of template text/source by command line.

Additionally, applying unix filter to parts of input stream. you can write markdown / pug inside your source code.

Examples

Embedding verion

$ cat example.js 
console.log("version is @PARTPIPE@VERSION@PARTPIPE@");

$ partpipe VERSION=1.2.0 -O destDir/ -- example.js
$ cat destDir/example.js
console.log('version is 1.2.0');

Embedding current date

$ cat LICENSE
Copyright 2017-@PARTPIPE@!date +Y@PARTPIPE@ Your Name

$ partpipe -O destDir/ -- LICENSE
$ cat destDir/LICENSE
Copyright 2017-2019 Your Name

ifdef / endif like

$ cat expample.js
@PARTPIPE@RELEASE
console.log('relase build')
@PARTPIPE@
@PARTPIPE@DEBUG
console.log('debug build')
@PARTPIPE@

$ partpipe RELEASE= DEBUG  -O destDir/ -- example.js
$ cat expmple.js
console.log('debug build)'

Applying unix filter to parts of a template

$ cat example.js
var html=`
@PARTPIPE@|md2html
# Hello World
This is a greeting application.
@PARTPIPE@
`;

$ partpipe -O destDir/ -- example.js
$ cat destDir/example.js
var html=`
<H1>Hello World</H1>
<p>This is a greeting application.</p>
`;

Install

sudo npm install -g partpipe

Usage

partpipe [<options>] [<TAG>[=<replacetext>]]... -O <outputdir> [-- files1 files2 ...]
version -
Copyright(c) 2017-2019,@kssfilo(https://kanasys.com/gtech/)
A command line tool,like C-preprocessor/sed/awk/perl.for embedding version/date/any data to template text/source.

Like #ifdef, you can enable/disable parts of template text/source by command line.

Additionally, applying unix filter to parts of input stream. you can write markdown / pug inside your source code.

Options

- h            show this usage
- d            debug mode
- o <filename> destination file name(default:stdout). use -O in multi-file mode
- O <dirname>  destination dir.file name will be same as input filename or partipe.out. 
- i <filename> input file name(default:stdin). 
- c            clear contents of unknown tag(default:passthrough)
- s            show contents of unknown tag(default:passthrough)
- w            error on unknown tag(default:paththrough)
- f <string>   use <string> as block separator(default:@PARTPIPE@)
- I            don't process indents
- C            old mode(ver 0.x.x compatible)

you can specify multi-file like this '-i file1 -i file2 ..' or '-- file1 file2 *.txt ..'

Tags

<TAG>=<replacetext>  replaces @PARTPIPE@<TAG>@PARTPIPE@ with <replacetext>. e.g. 'VERSION=1.2.0' replaces '@PARTPIPE@VERSION@PARTPIPE@'

<TAG>  shows   <block> of @PARTPIPE@<TAG>;<block>@PARTPIPE@ e.g. 'DEBUG' replaces '@PARTPIPE@DEBUG;console.log("debug mode")@PARTPIPE@' to 'console.log("debug mode")'
<TAG>= removes <block> of @PARTPIPE@<TAG>;<block>@PARTPIPE@ e.g. 'DEBUG=' replaces '@PARTPIPE@DEBUG;console.log("debug mode")@PARTPIPE@' to ''

<TAG>@<command> apply <command> to <block> of @PARTPIPE@TAG;<block>@PARTPIPE@ e.g. "MD@md2html" applys '@PARTPIPE@MD;# title@PARTPIPE@' to '<h1>titile</h1>'
# you can omit <block>. like '@PARTPIPE@DATE@PARTPIPE' in template text and 'DATE@date +%m%d%Y'. in command like. result will be '17/07/2019'

Examples

Replace by tag

$ cat example.js
console.log("version is @PARTPIPE@VERSION@PARTPIPE@");

$ partpipe VERSION=1.2.0 -O destDir/ -- example.js
$ cat destDir/example.js
console.log('version is 1.2.0');

Show/Remove by tag like #ifdef

$ cat example.js
@PARTPIPE@RELEASE;console.log('release build');@PARTPIPE@
@PARTPIPE@DEBUG;console.log('debug build');@PARTPIPE@

$ partpipe RELEASE DEBUG=  -O destDir/ -- example.js
$ cat destDir/example.js
console.log('release build');

$ partpipe RELEASE= DEBUG  -O destDir/ -- example.js
$ cat destDir/example.js
console.log('debug build');

multi-line

$ cat expample.js
@PARTPIPE@RELEASE
console.log('release build')
@PARTPIPE@
@PARTPIPE@DEBUG
console.log('debug build')
@PARTPIPE@

$ partpipe RELEASE= DEBUG  -O destDir/ -- example.js
console.log('debug build');

Embedding date or any command result

$ cat LICENSE
Copyright 2017-@PARTPIPE@!date +Y@PARTPIPE@ Your Name

$ partpipe -O destDir/ -- LICENSE
$ cat destDir/LICENSE
Copyright 2017-2019 Your Name

if tag is start by '!', partpipe treats it as command line. you can embed date or web data(by curl/norl) or everything

Applying unix filter to parts of template

$ cat example.js
var html=`
@PARTPIPE@|md2html
# Hello World
This is a greeting application.
@PARTPIPE@
`;

$ partpipe -O destDir/ -- example.js
$ cat destDir/example.js
var html=`
<H1>Hello World</H1>
<p>This is a greeting application.</p>
`;

if tag is start by '|', partpipe also treats it as command line. then inject the block to this stdin.

you can write markdown or pug in your program code. off course, any unix filter can be used such as sort / uniq.

Specify unix filter or any command in command line

$ cat example.js
var html=`
@PARTPIPE@MARKDOWN
# Hello World
This is a greeting application.
@PARTPIPE@
`;

$ partpipe 'MARKDOWN@md2html' -O destDir -- example.js
$ cat example.js
var html=`
<H1>Hello World</H1>
<p>This is a greeting application.</p>
`;

you can specify filter by command line. embed like normal tag. then add '@' in partpipe command line.

Use as module

var partpipe=require("partpipe");

var input=`Colors:
@PARTPIPE@|sort|uniq
Red
Blue
Green
Blue
Red
@PARTPIPE@`;

partpipe(input).then((result)=>console.log(result));

Change Log

  • 1.0.x:breaking change! @ and = are swapped on command line/adds -w option/rewriting documents/mitting ; on inline/new separator/-C mode/new debug line/multipule input mode
  • 1.0.x:use -C option(compatible mode) for scripts for 0.x
  • 0.4.x:changes tag format to @PARTPIPE@TAG (@PARTPIPE@=TAG is also ok)
  • 0.4.x:replace with text by command line (TAG@Text)
  • 0.4.x:remove tag content by command line (TAG@)
  • 0.4.x:show tag content by command line (TAG)
  • 0.3.x:added -s/-c option
  • 0.2.x:added tag mode(@PARTPIPE@=TAG)
  • 0.1.x:first release