Skip to content

Commit

Permalink
Merge pull request #51 from rmarscher/template-file
Browse files Browse the repository at this point in the history
Ability to use a custom template file
  • Loading branch information
joaosa committed Apr 9, 2015
2 parents 026429e + f8e04b9 commit 4947789
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
5 changes: 3 additions & 2 deletions Readme.md
Expand Up @@ -13,8 +13,9 @@ Usage: migrate [options] [command]
Options:
-c, --chdir <path> change the working directory
--state-file <path> set path to state file (migrations/.migrate)
-c, --chdir <path> change the working directory
--state-file <path> set path to state file (migrations/.migrate)
--template-file <path> set path to template file to use for new migrations
Commands:
Expand Down
9 changes: 6 additions & 3 deletions bin/migrate
Expand Up @@ -36,9 +36,9 @@ var usage = [
, ''
, ' Options:'
, ''
, ' -c, --chdir <path> change the working directory'
, ' --state-file <path> set path to state file (migrations/.migrate)'
, ''
, ' -c, --chdir <path> change the working directory'
, ' --state-file <path> set path to state file (migrations/.migrate)'
, ' --template-file <path> set path to template file to use for new migrations'
, ' Commands:'
, ''
, ' down [name] migrate down till given migration'
Expand Down Expand Up @@ -97,6 +97,9 @@ while (args.length) {
case '--state-file':
options.stateFile = required();
break;
case '--template-file':
template = fs.readFileSync(required());
break;
default:
if (options.command) {
options.args.push(arg);
Expand Down
13 changes: 13 additions & 0 deletions examples/cli/migrations/template.js
@@ -0,0 +1,13 @@
// use `migrate create add-pets --template-file migrations/template.js`

'use strict';

var db = require('./db');

exports.up = function(next){
next();
};

exports.down = function(next){
next();
};

0 comments on commit 4947789

Please sign in to comment.