diff options
author | Johannes Zellner <johannes@nebulon.de> | 2015-06-27 17:28:23 +0200 |
---|---|---|
committer | Johannes Zellner <johannes@nebulon.de> | 2015-06-27 17:28:23 +0200 |
commit | eb83e4daa3726d3e7f12c513a19d212b709dadff (patch) | |
tree | 00b2b5c41cffbe738d23cc2a026fa62a97358d90 /cli | |
parent | 8c3ae0719e1f7d266ee04d86e7e1c3756745d372 (diff) | |
download | Surfer-eb83e4daa3726d3e7f12c513a19d212b709dadff.tar.gz Surfer-eb83e4daa3726d3e7f12c513a19d212b709dadff.tar.zst Surfer-eb83e4daa3726d3e7f12c513a19d212b709dadff.zip |
Use del instead of rimraf
Diffstat (limited to 'cli')
-rw-r--r-- | cli/actions.js | 5 | ||||
-rwxr-xr-x | cli/surfer.js | 1 |
2 files changed, 4 insertions, 2 deletions
diff --git a/cli/actions.js b/cli/actions.js index 592d809..00ffb6f 100644 --- a/cli/actions.js +++ b/cli/actions.js | |||
@@ -46,7 +46,7 @@ function login(server) { | |||
46 | config.set('server', server); | 46 | config.set('server', server); |
47 | } | 47 | } |
48 | 48 | ||
49 | function put(filePath, otherFilePaths) { | 49 | function put(filePath, otherFilePaths, options) { |
50 | checkConfig(); | 50 | checkConfig(); |
51 | 51 | ||
52 | var files = collectFiles([ filePath ].concat(otherFilePaths)); | 52 | var files = collectFiles([ filePath ].concat(otherFilePaths)); |
@@ -54,7 +54,7 @@ function put(filePath, otherFilePaths) { | |||
54 | async.eachSeries(files, function (file, callback) { | 54 | async.eachSeries(files, function (file, callback) { |
55 | var relativeFilePath = path.resolve(file).slice(process.cwd().length + 1); | 55 | var relativeFilePath = path.resolve(file).slice(process.cwd().length + 1); |
56 | 56 | ||
57 | console.log('Uploading file %s', relativeFilePath.cyan); | 57 | console.log('Uploading file %s -> %s', relativeFilePath.cyan, ((options.destination ? options.destination : '') + '/' + relativeFilePath).cyan); |
58 | 58 | ||
59 | superagent.put(config.server() + API + relativeFilePath).attach('file', file).end(callback); | 59 | superagent.put(config.server() + API + relativeFilePath).attach('file', file).end(callback); |
60 | }, function (error) { | 60 | }, function (error) { |
@@ -90,6 +90,7 @@ function del(filePath) { | |||
90 | 90 | ||
91 | var relativeFilePath = path.resolve(filePath).slice(process.cwd().length + 1); | 91 | var relativeFilePath = path.resolve(filePath).slice(process.cwd().length + 1); |
92 | superagent.del(config.server() + API + relativeFilePath).end(function (error, result) { | 92 | superagent.del(config.server() + API + relativeFilePath).end(function (error, result) { |
93 | if (error.status === 404) return console.log('No such file or directory'); | ||
93 | if (error) return console.log('Failed', result ? result.body : error); | 94 | if (error) return console.log('Failed', result ? result.body : error); |
94 | console.log('Success', result.body); | 95 | console.log('Success', result.body); |
95 | }); | 96 | }); |
diff --git a/cli/surfer.js b/cli/surfer.js index d906d62..fbc95b6 100755 --- a/cli/surfer.js +++ b/cli/surfer.js | |||
@@ -15,6 +15,7 @@ program.command('login') | |||
15 | .action(actions.login); | 15 | .action(actions.login); |
16 | 16 | ||
17 | program.command('put <file> [files...]') | 17 | program.command('put <file> [files...]') |
18 | .option('-d --destination <folder>', 'Destination folder. This is prepended to the relative <file> path') | ||
18 | .description('Put a file') | 19 | .description('Put a file') |
19 | .action(actions.put); | 20 | .action(actions.put); |
20 | 21 | ||