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 f014bd26
authored
Dec 22, 2011
by
sdepold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sequelize binary. can handle init
1 parent
c0e1dc72
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
3 deletions
bin/sequelize
bin/sequelize
100644 → 100755
View file @
f014bd2
#!/usr/bin/env node
var
path
=
require
(
"path"
)
var
path
=
require
(
"path"
)
,
fs
=
require
(
"fs"
)
,
program
=
require
(
"commander"
)
,
configPath
=
__dirname
+
'/../config'
,
configFile
=
configPath
+
'/config.json'
,
configPathExists
=
path
.
existsSync
(
configPath
)
,
configFileExists
=
path
.
existsSync
(
configFile
)
if
(
path
.
existsSync
(
__dirname
+
'/../config/config.json'
))
{
var
writeConfig
=
function
(
config
)
{
!
configPathExists
&&
fs
.
mkdirSync
(
configPath
)
config
=
JSON
.
stringify
(
config
)
config
=
config
.
replace
(
'{'
,
'{\n'
)
config
=
config
.
replace
(
/,/g
,
",\n"
)
config
=
config
.
replace
(
'}'
,
"\n}"
)
fs
.
writeFileSync
(
configFile
,
config
)
}
program
.
version
(
'1.3.0'
)
.
option
(
'-i, --init'
,
'Initializes the project. Creates a config/config.json'
)
.
option
(
'-m, --migrate'
,
'Runs undone migrations'
)
.
option
(
'-f, --force'
,
'Forces the action to be done.'
)
.
parse
(
process
.
argv
)
if
(
program
.
migrate
)
{
if
(
configFileExists
)
{
}
else
{
throw
new
Error
(
'Please add a configuration file under config/config.json. You might run "sequelize --init".'
)
}
}
else
if
(
program
.
init
)
{
if
(
!
configFileExists
||
!!
program
.
force
)
{
writeConfig
({
username
:
"root"
,
password
:
null
,
database
:
'database'
,
host
:
'127.0.0.1'
})
console
.
log
(
'Successfully created config.json'
)
}
else
{
console
.
log
(
'A config.json already exists. Run "sequelize --init --force" to overwrite it.'
)
}
}
else
{
throw
new
Error
(
'Please add a configuration file under config/config.json
'
)
console
.
log
(
'Please define any params!
'
)
}
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