2.0.1 • Published 3 years ago
@tadashi/injection v2.0.1
Injection
Inject data into file
Install
$ npm i -S @tadashi/injection
Sample
This is the file that will be inject: script.js
const a = 'Horray';
alert(a);
This is the source file with the markup showing where is the place will be injected: input.html
<body>
<script>/* inject: ./script.js */</script>
</body>
Making injection specifying the output file
const injection = require('@tadashi/injection');
(async () => {
await injection('./input.html', './output.html', '\/\\*\\sinject:\\s([\\w./]+)\\s\\*\\/')
})()
Result: output.html
<body><script>const a = 'Horray';alert(a);</script></body>
API
injection(input, output)
Name | Type | Required | Default | Description |
---|---|---|---|---|
input | string | yes | - | Source file |
output | string | no | ./out | Result file |
pattern | string | no | <!--\\sinject:\\s([\\w./]+)\\s--> | RegExp pattern |
License
MIT © Thiago Lagden