
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Flexible generator, which makes your project clean and maintainable.
// Define rendering rule.
module.exports = {
path: 'have-a-nice-day.txt', // File path to write
tmpl: '.have-a-nice-day.txt.hbs', // Template file
force: true, // Overwrite each time
mode: '444', // As readyonly file
data: require('./my-datasource.json') // Data to render
}
Save this as .my-first-bud.bud , then running
$ coz render ".my-first-bud.bud"
will do the magic.
The basic idea of coz is that creating files from files.
coz render command.
Automation. Generating files makes your project clean and maintainable.
You can define a single datasource and distribute it in various forms.
For example,
coz is available as an npm package.
# Install coz as a global module.
$ npm install coz -g
Or you can install it without -g option and use Programmatic API.
For more details, see tutorial section "01 - Installing coz".
.who-likes-what.txt.bud (bud file)
/**
* .who-likes-what.txt.bud
* This is a bud file for "examples/01-minimum-demo"
*/
// Exports as a Node.js module.
module.exports = {
// Template string. By default, parsed by Handlebars engine.
tmpl: '{{#each members}}Hi, my name is {{@key}}. I like {{this}}.\n{{/each}}',
// Overwrite when already existing.
force: true,
// File path to write out.
path: 'who-likes-what.txt',
// File permission.
mode: '444',
// Data to render.
data: {
members: {
"Mai": "apple",
"Tom": "Orange",
"Rita": "Banana"
}
}
};
As you see, .bud file is actuary a JavaScript file and could be exported a Node.js module.
Save this file as .who-likes-what.txt.bud and then, run:
# Render the bud file
$ coz render ".who-likes-what.txt.bud"
This will generate a file named who-likes-what.txt.
For more details, see tutorial section "02 - Rendering bud files".
### Programmatic APIcoz provides programmatic API which enables you to execute coz commands from Node.js program.
#!/usr/bin/env node
/**
* run_rendering.js
* This is an executable file for "examples/04-from-programmatic-api/run_rendering.js"
*/
var coz = require('coz');
// Render .bud files.
coz.render([
'**/.*.bud'
], function (err) {
console.log(err ? err : 'Done!');
});
For more details, see tutorial section "[04 - Using programmatic API][04_using_programmatic_a_p_i_url]".
A bud contains file meta data like witch template to use, where to render it, what permission to give, and so on.
You can specify bud data by writing .bud file, which is actually a javascript file and could be written in Node.js format.
module.exports = {
path: 'my_file.txt',
tmpl: '.my_file.txt.hbs',
data: require('./.my_data')
}
And bud could be an array like:
module.exports = [
{ path: 'my_file.txt', /* ... */ },
{ path: 'my_other_file.txt', /* ... */ },
]
Or an async function.
module.exports = function(callback){
myAsync((data) => {
let error = null
callback(err, data)
})
}
For more details, see tutorial section "03 - Mastering coz bud".
List of properties configurable in bud files.
| Name | Type | Default | Description |
|---|---|---|---|
engine | string | object | 'handlebars' |
cwd | string | process.cwd() | Working directory path |
data | object | Data which template render with | |
mkdirp | boolean | false | Make parent directories if needed |
setup | object | Optional settings for template engine | |
force | boolean | false | Should overwrite file when already exists, or not |
mode | string | number | '644' |
path | string | Destination file path. If not provided, guess from bud file path | |
tmpl | string | function | 'json' |
Support this project and others by okunishinishi via gratipay.
This software is released under the MIT License.
FAQs
Flexible generator, which makes your project clean and maintainable.
We found that coz demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.