Socket
Socket
Sign inDemoInstall

reversible-preproc-cli

Package Overview
Dependencies
9
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    reversible-preproc-cli

CLI for reversible-preproc


Version published
Maintainers
1
Install size
323 kB
Created

Readme

Source

reversible-preproc-cli

Outline

reversible-preproc-cli is a command line interface on top of the npm core module reversible-preproc.

The preproc defines are supplied as a file input, or on the command line.
This differs from, for example, C, where the defines are inscribed in the file to be processed. The defines uses a Javascript style format allowing structured properties and values. E.g.,

{
    DEBUG: 2,
    select : 1,
    configs : [{
        A: 1, B: 2 
    }, {
        A: 2, B: 3 
    }]
}

The file to processed of course contains conditional statements (conditioned on the defines).
These conditional statements may be written in either of two styles:

  • Psuedo Javascript ... (which doesn't use eval)
  • Real javascript functions ... (which do use eval)

The Psuedo Javascript is briefer and more natural, but the Real Javascript is almighty.

For more details about the defines and the conditional statements, see the documentation for reversible-preproc on npm or github.

The "reversible" moniker indicates that it is suitable for lightweight switching back and forth between configuations (e.g., in-place). The deactivated regions are marked with annotated comments (//!!) enabling the preprocessor to remove them for a different configuration. Repeated applications of the same defines are idempotent.

Regexp is not used. Neither is all text searched. Only lines beginning with comment marks (e.g. //), are further processed as potential processing command lines. This makes processing relatively fast.

The rest of this document describes the CLI arguments.

CLI arguments

  • -i --infile The file to be transformed. If omitted stdin will be used.

  • -o --outfile The file to which to write the transformed data. If omitted stdout will be used.

  • -f --deffile The file containing the JSON variable properties.

  • -l --defline To pass the JSON defines inline. Due to the need to escape quotations marks this option is only usefule for simple cases.

  • -t --testout Instead of outputting the transformed input, the output contains one line for conditional statement with the form: <T or F> <the conditional statement>

NOTE: Only one, and exactly one, of the '--deffile' and '--defline' options can/must be used.

changes: v1.0.1 Mofied to work with Windows style EOL ('\r\n').

Keywords

FAQs

Last updated on 03 Sep 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc