Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .gitignore creation to hz init #681

Merged
merged 3 commits into from
Jul 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions cli/src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ token_secret = "${crypto.randomBytes(64).toString('base64')}"
# secret = "0000000000000000000000000000000"
`

const gitignore = () => `\
rethinkdb_data
**/*.log
.hz/secrets.toml
`

const addArguments = (parser) => {
parser.addArgument([ 'projectName' ],
{ action: 'store',
Expand Down Expand Up @@ -228,6 +234,18 @@ function populateDir(projectName, dirWasPopulated, chdirTo, dirName) {
// read/write only
};

// Create .gitignore if it doesn't exist
if (!fileExists('.gitignore')) {
fs.appendFileSync(
'.gitignore',
gitignore(),
permissionGeneral
);
console.info(`Created ${niceDir}.gitignore`);
} else {
console.info('.gitignore already exists, not touching it.');
}

// Create .hz/config.toml if it doesn't exist
if (!fileExists('.hz/config.toml')) {
fs.appendFileSync(
Expand Down
5 changes: 5 additions & 0 deletions cli/test/init.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ describe('hz init', () => {
assertDirExists(projectDir, '.hz');
done();
});
it('creates the .gitignore file', (done) => {
initCommand.runCommand(runOptions);
assertFileExists(`${projectDir}`, '.gitignore');
done();
});
it('creates the .hz/config.toml file', (done) => {
initCommand.runCommand(runOptions);
assertFileExists(`${projectDir}/.hz`, 'config.toml');
Expand Down