Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 6953605b
authored
Feb 07, 2014
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for --coffee
1 parent
a93bb7d1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
bin/sequelize
test/sequelize.executable.test.js
bin/sequelize
View file @
6953605
...
@@ -9,9 +9,9 @@ var path = require("path")
...
@@ -9,9 +9,9 @@ var path = require("path")
,
url
=
require
(
"url"
)
,
url
=
require
(
"url"
)
var
configuration
=
{
var
configuration
=
{
configFile
:
process
.
cwd
()
+
'/config/config.json'
,
configFile
:
process
.
cwd
()
+
'/config/config.json'
,
environment
:
process
.
env
.
NODE_ENV
||
'development'
,
environment
:
process
.
env
.
NODE_ENV
||
'development'
,
version
:
require
(
__dirname
+
'/../package.json'
).
version
,
version
:
require
(
__dirname
+
'/../package.json'
).
version
,
migrationsPath
:
process
.
cwd
()
+
'/migrations'
migrationsPath
:
process
.
cwd
()
+
'/migrations'
}
}
...
@@ -152,6 +152,7 @@ program
...
@@ -152,6 +152,7 @@ program
.
option
(
'-c, --create-migration [migration-name]'
,
'Creates a new migration.'
)
.
option
(
'-c, --create-migration [migration-name]'
,
'Creates a new migration.'
)
.
option
(
'-U, --url <url>'
,
'Database url. An alternative to a config file'
)
.
option
(
'-U, --url <url>'
,
'Database url. An alternative to a config file'
)
.
option
(
'--config <config_file>'
,
'Specifies alternate config file.'
)
.
option
(
'--config <config_file>'
,
'Specifies alternate config file.'
)
.
option
(
'--coffee'
,
'Consider coffee script files as migration source.'
)
.
parse
(
process
.
argv
)
.
parse
(
process
.
argv
)
if
(
typeof
program
.
config
===
'string'
)
{
if
(
typeof
program
.
config
===
'string'
)
{
...
@@ -205,7 +206,12 @@ if (program.migrate || program.undo) {
...
@@ -205,7 +206,12 @@ if (program.migrate || program.undo) {
var
sequelize
=
new
Sequelize
(
config
.
database
,
config
.
username
,
config
.
password
,
options
)
var
sequelize
=
new
Sequelize
(
config
.
database
,
config
.
username
,
config
.
password
,
options
)
,
migratorOptions
=
{
path
:
configuration
.
migrationsPath
}
,
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
)
{
if
(
program
.
undo
)
{
migrator
.
findOrCreateSequelizeMetaDAO
().
success
(
function
(
Meta
)
{
migrator
.
findOrCreateSequelizeMetaDAO
().
success
(
function
(
Meta
)
{
...
...
test/sequelize.executable.test.js
View file @
6953605
...
@@ -147,7 +147,11 @@ describe(Support.getTestDialectTeaser("Executable"), function() {
...
@@ -147,7 +147,11 @@ describe(Support.getTestDialectTeaser("Executable"), function() {
var
prepare
=
function
(
callback
)
{
var
prepare
=
function
(
callback
)
{
exec
(
"rm -rf ./*"
,
{
cwd
:
__dirname
+
'/tmp'
},
function
(
error
,
stdout
)
{
exec
(
"rm -rf ./*"
,
{
cwd
:
__dirname
+
'/tmp'
},
function
(
error
,
stdout
)
{
exec
(
"../../bin/sequelize --init"
,
{
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
)
{
exec
(
"cat ../support.js|sed s,/../,/../../, > ./support.js"
,
{
cwd
:
__dirname
+
'/tmp'
},
function
(
error
,
stdout
)
{
var
dialect
=
Support
.
getTestDialect
()
var
dialect
=
Support
.
getTestDialect
()
,
config
=
require
(
__dirname
+
'/config/config.js'
)
,
config
=
require
(
__dirname
+
'/config/config.js'
)
...
@@ -208,9 +212,11 @@ describe(Support.getTestDialectTeaser("Executable"), function() {
...
@@ -208,9 +212,11 @@ describe(Support.getTestDialectTeaser("Executable"), function() {
})
})
})([
})([
'--migrate'
,
'--migrate'
,
'--migrate --coffee'
,
'--migrate --config ../tmp/config/config.json'
,
'--migrate --config ../tmp/config/config.json'
,
'--migrate --config '
+
path
.
join
(
__dirname
,
'tmp'
,
'config'
,
'config.json'
),
'--migrate --config '
+
path
.
join
(
__dirname
,
'tmp'
,
'config'
,
'config.json'
),
'-m'
,
'-m'
,
'-m --coffee'
,
'-m --config ../tmp/config/config.json'
,
'-m --config ../tmp/config/config.json'
,
'-m --config '
+
path
.
join
(
__dirname
,
'tmp'
,
'config'
,
'config.json'
)
'-m --config '
+
path
.
join
(
__dirname
,
'tmp'
,
'config'
,
'config.json'
)
])
])
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment