
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
hcp - handlebars-copy
Like cp, but with Handlebars template
npm install hcp
$ hcp <files...> [options]
Options:
--help Show this help output
--version Show package version
--debug Show extended debug output
Examples:
$ hcp package.json package.copy.json
$ hcp index.html package.json app/ --name foobar
$ hcp_name="foobar" hcp text/examples/* ~/dev/myapp/app
hcp is a CLI tool similar to the cp
command.
File copy is done using Streams, with lodash.template
parsing files if they
have template placeholders {{ ... }}
.
Handlebars template are executed in the context of the following object:
Object.assign({}, env, opts)
// where `env` and `opts` have the following structure
{
env: {
PATH: '...',
...
},
opts: {
debug: true,
name: 'Foobar'
}
}
The templates context is a merged version of various sources, with the following order of precedence:
process.env
variables begining with hcp_
Handlebars templates can have any number of placeholders. Variables are either available in the context object, or automatically prompted for the user to enter a value.
Skipping a prompt is then available with --name Value
.
To enable it, inquirer must be installed and available in node_modules
.
npm i inquirer -D
If not installed, prompts are not generated.
JSON files are merged together with destination, if it already exists.
hcp test/examples/package.json test/output.json.
hcp('test/examples/package.json test/output.json')
.expect(0)
.end(() => {
assert.deepEqual(require('./output.json'), {
name: 'input',
description: '',
foo: 'bar'
});
done();
});
hcp test/examples/package.json test/existing.json.
hcp('test/examples/package.json test/existing.json')
.expect(0, (err) => {
if (err) return done(err);
assert.deepEqual(require('./existing.json'), {
name: 'output',
description: '...',
foo: 'bar',
bar: true
});
fs.writeFile(path.join(__dirname, 'existing.json'), JSON.stringify({
name: 'output',
description: '...',
bar: true
}, null, 2), done);
});
hcp test/examples/* test/output/ --name blah --description desc --foo bar.
hcp('test/examples/* test/output/ --name blah --description desc --foo bar')
.expect(0, (err) => {
if (err) return done(err);
assert.deepEqual(require('./output/package.json'), {
name: 'input',
description: '',
foo: 'bar'
});
assert.deepEqual(require('./output/tpl.json'), {
name: 'blah',
description: 'desc',
foo: 'bar'
});
done();
});
FAQs
Like cp, but with Handlebars template
We found that hcp 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
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.