Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
PUBLIC
/
surfer-okd
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 eb83e4da
authored
Jun 27, 2015
by
Johannes Zellner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use del instead of rimraf
1 parent
8c3ae071
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
6 deletions
cli/actions.js
cli/surfer.js
package.json
src/files.js
cli/actions.js
View file @
eb83e4d
...
...
@@ -46,7 +46,7 @@ function login(server) {
config
.
set
(
'server'
,
server
);
}
function
put
(
filePath
,
otherFilePaths
)
{
function
put
(
filePath
,
otherFilePaths
,
options
)
{
checkConfig
();
var
files
=
collectFiles
([
filePath
].
concat
(
otherFilePaths
));
...
...
@@ -54,7 +54,7 @@ function put(filePath, otherFilePaths) {
async
.
eachSeries
(
files
,
function
(
file
,
callback
)
{
var
relativeFilePath
=
path
.
resolve
(
file
).
slice
(
process
.
cwd
().
length
+
1
);
console
.
log
(
'Uploading file %s
'
,
relativeFilePath
.
cyan
);
console
.
log
(
'Uploading file %s
-> %s'
,
relativeFilePath
.
cyan
,
((
options
.
destination
?
options
.
destination
:
''
)
+
'/'
+
relativeFilePath
)
.
cyan
);
superagent
.
put
(
config
.
server
()
+
API
+
relativeFilePath
).
attach
(
'file'
,
file
).
end
(
callback
);
},
function
(
error
)
{
...
...
@@ -90,6 +90,7 @@ function del(filePath) {
var
relativeFilePath
=
path
.
resolve
(
filePath
).
slice
(
process
.
cwd
().
length
+
1
);
superagent
.
del
(
config
.
server
()
+
API
+
relativeFilePath
).
end
(
function
(
error
,
result
)
{
if
(
error
.
status
===
404
)
return
console
.
log
(
'No such file or directory'
);
if
(
error
)
return
console
.
log
(
'Failed'
,
result
?
result
.
body
:
error
);
console
.
log
(
'Success'
,
result
.
body
);
});
...
...
cli/surfer.js
View file @
eb83e4d
...
...
@@ -15,6 +15,7 @@ program.command('login')
.
action
(
actions
.
login
);
program
.
command
(
'put <file> [files...]'
)
.
option
(
'-d --destination <folder>'
,
'Destination folder. This is prepended to the relative <file> path'
)
.
description
(
'Put a file'
)
.
action
(
actions
.
put
);
...
...
package.json
View file @
eb83e4d
...
...
@@ -24,12 +24,12 @@
"connect-lastmile"
:
"0.0.10"
,
"connect-timeout"
:
"^1.6.2"
,
"debug"
:
"^2.2.0"
,
"del"
:
"^1.2.0"
,
"ejs"
:
"^2.3.1"
,
"express"
:
"^4.12.4"
,
"mkdirp"
:
"^0.5.1"
,
"morgan"
:
"^1.6.0"
,
"multiparty"
:
"^4.1.2"
,
"rimraf"
:
"^2.4.0"
,
"safetydance"
:
"0.0.16"
,
"superagent"
:
"^1.2.0"
,
"underscore"
:
"^1.8.3"
...
...
src/files.js
View file @
eb83e4d
...
...
@@ -3,7 +3,7 @@
var
fs
=
require
(
'fs'
),
path
=
require
(
'path'
),
ejs
=
require
(
'ejs'
),
r
imraf
=
require
(
'rimraf
'
),
r
m
=
require
(
'del
'
),
debug
=
require
(
'debug'
)(
'files'
),
mkdirp
=
require
(
'mkdirp'
),
HttpError
=
require
(
'connect-lastmile'
).
HttpError
,
...
...
@@ -116,9 +116,9 @@ function del(req, res, next) {
fs
.
stat
(
absoluteFilePath
,
function
(
error
,
result
)
{
if
(
error
)
return
next
(
new
HttpError
(
404
,
error
));
r
imraf
(
absoluteFilePath
,
function
(
error
)
{
r
m
(
absoluteFilePath
,
function
(
error
,
result
)
{
if
(
error
)
return
next
(
new
HttpError
(
500
,
'Unable to remove'
));
next
(
new
HttpSuccess
(
200
,
{}));
next
(
new
HttpSuccess
(
200
,
{
entries
:
result
}));
});
});
}
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