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 4c23c8a1
authored
May 11, 2013
by
terraflubb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Throw nicer errors when we can't read config.json
And quit with a code after outputting it.
1 parent
6f65e6de
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
8 deletions
bin/sequelize
bin/sequelize
View file @
4c23c8a
...
@@ -51,17 +51,23 @@ var createMigrationsFolder = function(force) {
...
@@ -51,17 +51,23 @@ var createMigrationsFolder = function(force) {
}
}
var
readConfig
=
function
()
{
var
readConfig
=
function
()
{
var
config
try
{
try
{
var
config
=
JSON
.
parse
(
fs
.
readFileSync
(
configFile
))
config
=
fs
.
readFileSync
(
configFile
)
}
catch
(
e
)
{
throw
new
Error
(
'Error reading "config/config.json".'
)
}
if
(
config
[
environment
])
{
try
{
config
=
config
[
environment
]
config
=
JSON
.
parse
(
config
)
}
}
catch
(
e
)
{
throw
new
Error
(
'Error parsing "config/config.json" as JSON.'
)
}
return
config
if
(
config
[
environment
])
{
}
catch
(
e
)
{
config
=
config
[
environment
]
throw
new
Error
(
'The config.json is not available or contains invalid JSON.'
)
}
}
return
config
}
}
program
program
...
@@ -81,9 +87,16 @@ console.log("Using environment '" + environment + "'.")
...
@@ -81,9 +87,16 @@ console.log("Using environment '" + environment + "'.")
if
(
program
.
migrate
)
{
if
(
program
.
migrate
)
{
if
(
configFileExists
)
{
if
(
configFileExists
)
{
var
config
=
readConfig
()
var
config
,
options
=
{}
,
options
=
{}
try
{
config
=
readConfig
()
}
catch
(
e
)
{
console
.
log
(
e
.
message
)
process
.
exit
(
1
)
}
_
.
each
(
config
,
function
(
value
,
key
)
{
_
.
each
(
config
,
function
(
value
,
key
)
{
if
([
'database'
,
'username'
,
'password'
].
indexOf
(
key
)
==
-
1
)
{
if
([
'database'
,
'username'
,
'password'
].
indexOf
(
key
)
==
-
1
)
{
options
[
key
]
=
value
options
[
key
]
=
value
...
...
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