
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
uni-preprocessor
Advanced tools
A (Cpp-like?) preprocessor for any programming language or any config texts or just plain text. Written in TypeScript/NodeJS
An util library / cli tool for preprocessing any type of files.
Currently used implementation is ifdef.js, written in Dave Balmer. You can find more about how it works there.
The original project is just a cli program and does not provides any export functions.
This project exports a function ifdef_js.process_string(...), it receives string as the file content, and output the preprocessed string file content. For more information, you can see the function comments.
import upp from "uni-preprocessor"
const file_content = ...
const targets = ["windows", "app", "melty_kiss"]
const [processed_result, warnings] = upp.ifdef_js.process_string(file_content, targets)
This package exported two CLI command, uni-preprocessor and upp. These two command are equivalent to each other.
You can use npm install --global uni-preprocessor to install the CLI to your computer, or use npm install --save-dev uni-preprocessor to install this CLI to your project develop environment.
Then, just use $ upp --help to see the help page. There are helps and examples for the CLI.
For now, CLI does not supports the following features yet.
You can change #ifdef to another name such as #iftarget etc. using the IfdefJsConfig like below:
const result = ifdefJs.process_string(
source, ["target-a"],
{
alternative_target_tagname: "def"
}
)
Set the alternative_target_tagname to a string
like "x" will let ifdefJs uses #ifx as #ifdef, #ifnx as #ifndef, while #endif will still be #endif.
const result = ifdefJs.process_string(
source, ["target-a"],
{
alternative_target_tagname: {
start: "ifdef",
start_rev: "ifndef"
end: "endif"
}
}
)
You can also set the alternative_target_name to an
object that contains start, start_rev, end.
In this case, start's value indicates ifdef,
start_rev indicates ifndef, end indicates
endif. Notice that you should not add # here
and the ifdefJs will still need a prefixed #.
You can use IfdefJsConfig.defines to make the
ifdefJs find and replace the texts. For example,
if you want to change {{version}} to 0.0.1,
just set configs like this:
const result = ifdefJs.process_string(
source, ["target-a"],
{
defines: {
"{{version}}": "0.0.1"
}
}
)
You can also set multiple find-and-replace pairs, ifdefJs will find-and-replace them in order. Notice that the find-and-replace cannot find across lines, while match multiple times in one line is supported.
const result = ifdefJs.process_string(
source, ["target-a"],
{
defines: {
"{{id}}": "my-hp"
"{{name}}": "My Hypothetical Project",
"{{version}}": "0.0.1",
// due to this match string have \n,
// means it must match across line,
// but ifdefJs does not supports matches
// across line, so this find-and-replace
// pair will never be matched.
"# my-hp\n": "# My Hypothetical Project\n"
}
}
)
FAQs
A (Cpp-like?) preprocessor for any programming language or any config texts or just plain text. Written in TypeScript/NodeJS
We found that uni-preprocessor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
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.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.