不要怂,就是干,撸起袖子干!

Commit 6953605b by Sascha Depold

Support for --coffee

1 parent a93bb7d1
......@@ -152,6 +152,7 @@ program
.option('-c, --create-migration [migration-name]', 'Creates a new migration.')
.option('-U, --url <url>', 'Database url. An alternative to a config file')
.option('--config <config_file>', 'Specifies alternate config file.')
.option('--coffee', 'Consider coffee script files as migration source.')
.parse(process.argv)
if(typeof program.config === 'string') {
......@@ -205,7 +206,12 @@ if (program.migrate || program.undo) {
var sequelize = new Sequelize(config.database, config.username, config.password, options)
, migratorOptions = { path: configuration.migrationsPath }
, migrator = sequelize.getMigrator(migratorOptions)
if (program.coffee) {
migratorOptions = _.merge(migratorOptions, { filesFilter: /\.js$|\.coffee$/ })
}
var migrator = sequelize.getMigrator(migratorOptions)
if (program.undo) {
migrator.findOrCreateSequelizeMetaDAO().success(function(Meta) {
......
......@@ -147,7 +147,11 @@ describe(Support.getTestDialectTeaser("Executable"), function() {
var prepare = function(callback) {
exec("rm -rf ./*", { cwd: __dirname + '/tmp' }, function(error, stdout) {
exec("../../bin/sequelize --init", { cwd: __dirname + '/tmp' }, function(error, stdout) {
exec("cp ../assets/migrations/*-createPerson.js ./migrations/", { cwd: __dirname + '/tmp' }, function(error, stdout) {
var source = (flag.indexOf('coffee') === -1)
? "../assets/migrations/*-createPerson.js"
: "../assets/migrations/*-createPerson.coffee"
exec("cp " + source + " ./migrations/", { cwd: __dirname + '/tmp' }, function(error, stdout) {
exec("cat ../support.js|sed s,/../,/../../, > ./support.js", { cwd: __dirname + '/tmp' }, function(error, stdout) {
var dialect = Support.getTestDialect()
, config = require(__dirname + '/config/config.js')
......@@ -208,9 +212,11 @@ describe(Support.getTestDialectTeaser("Executable"), function() {
})
})([
'--migrate',
'--migrate --coffee',
'--migrate --config ../tmp/config/config.json',
'--migrate --config ' + path.join(__dirname, 'tmp', 'config', 'config.json'),
'-m',
'-m --coffee',
'-m --config ../tmp/config/config.json',
'-m --config ' + path.join(__dirname, 'tmp', 'config', 'config.json')
])
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!