Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
surfer-okd
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PUBLIC
surfer-okd
Commits
94176733
Commit
94176733
authored
Jul 01, 2015
by
Johannes Zellner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parse uri
parent
2594ccd4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
actions.js
cli/actions.js
+11
-3
No files found.
cli/actions.js
View file @
94176733
...
@@ -10,6 +10,7 @@ var superagent = require('superagent'),
...
@@ -10,6 +10,7 @@ var superagent = require('superagent'),
readlineSync
=
require
(
'readline-sync'
),
readlineSync
=
require
(
'readline-sync'
),
async
=
require
(
'async'
),
async
=
require
(
'async'
),
fs
=
require
(
'fs'
),
fs
=
require
(
'fs'
),
url
=
require
(
'url'
),
path
=
require
(
'path'
);
path
=
require
(
'path'
);
require
(
'colors'
);
require
(
'colors'
);
...
@@ -48,8 +49,11 @@ function collectFiles(filesOrFolders) {
...
@@ -48,8 +49,11 @@ function collectFiles(filesOrFolders) {
return
tmp
;
return
tmp
;
}
}
function
login
(
server
)
{
function
login
(
uri
)
{
if
(
server
[
server
.
length
-
1
]
===
'/'
)
server
=
server
.
slice
(
0
,
-
1
);
var
tmp
=
url
.
parse
(
uri
);
if
(
!
tmp
.
host
)
tmp
=
url
.
parse
(
'https://'
+
uri
);
var
server
=
'https://'
+
tmp
.
host
;
console
.
log
(
'Using server'
,
server
);
console
.
log
(
'Using server'
,
server
);
...
@@ -57,6 +61,10 @@ function login(server) {
...
@@ -57,6 +61,10 @@ function login(server) {
var
password
=
readlineSync
.
question
(
'Password: '
,
{
hideEchoBack
:
true
});
var
password
=
readlineSync
.
question
(
'Password: '
,
{
hideEchoBack
:
true
});
superagent
.
get
(
server
+
API
+
'/'
).
query
({
username
:
username
,
password
:
password
}).
end
(
function
(
error
,
result
)
{
superagent
.
get
(
server
+
API
+
'/'
).
query
({
username
:
username
,
password
:
password
}).
end
(
function
(
error
,
result
)
{
if
(
error
&&
error
.
code
===
'ENOTFOUND'
)
{
console
.
log
(
'No such server %s'
.
red
,
server
);
process
.
exit
(
1
);
}
if
(
result
.
status
===
401
)
{
if
(
result
.
status
===
401
)
{
console
.
log
(
'Login failed.'
);
console
.
log
(
'Login failed.'
);
process
.
exit
(
1
);
process
.
exit
(
1
);
...
@@ -70,7 +78,7 @@ function login(server) {
...
@@ -70,7 +78,7 @@ function login(server) {
gQuery
=
{
username
:
username
,
password
:
password
};
gQuery
=
{
username
:
username
,
password
:
password
};
console
.
log
(
'Done'
);
console
.
log
(
'Done'
.
green
);
});
});
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment