@losteth0/tsembed v1.0.3
TSEmbed
A TypeScript preprocessing tool for using text files as strings.
Note: This program was thrown together in an afternoon and into the night, and is kinda shit. Its just a quick and dirty solution until I make an actual TS preprocessor or find an existing one.
Why?
¯\_(ツ)_/¯
Depends on usecase, but personally I made it to let me have syntax highlighting on CSS that I needed to be in a .ts file as a string, and said file had to be minified, so I couldn't use let foo:string = fs.readFileSync('./bar.txt', 'utf8');
or something.
Usage
Simply create a string with the content of '%TSEMBED%', followed by a comment of //?{, followed by any JavaScript code that evaluates to a string, and then closed by }.
// TSEmbed example.
let helloWorldTxt:string = '%TSEMBED%'; //?{fs.readFileSync('./example.txt','utf8').replace(/\n/gm, '')}
console.log(helloWorldTxt);
Install
npm i @losteth0/tsembed
How to build
When using Node, I strongly reccomend using Yarn over NPM. Yarn caches packages you download so that they download quicker when you need them.
These instructions assume you have Git, Node.js, and Yarn installed.
git clone https://github.com/K4rakara/tsembed.git
cd tsembed
yarn install
yarn make
For a general NPM binary, run:
yarn pkg-node
For a platform specific binary, run:
yarn pkg tsembed.js --targets=latest-[YOUR PLATFORM HERE]-x64
See pkg's documentation for more details.