diff options
Diffstat (limited to 'cli/actions.js')
-rw-r--r-- | cli/actions.js | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/cli/actions.js b/cli/actions.js index 6f8faea..69ffa10 100644 --- a/cli/actions.js +++ b/cli/actions.js | |||
@@ -119,8 +119,9 @@ function put(filePath, otherFilePaths, options) { | |||
119 | console.log('Uploading file %s -> %s', relativeFilePath.cyan, destinationPath.cyan); | 119 | console.log('Uploading file %s -> %s', relativeFilePath.cyan, destinationPath.cyan); |
120 | 120 | ||
121 | superagent.put(config.server() + API + destinationPath).query(gQuery).attach('file', file).end(function (error, result) { | 121 | superagent.put(config.server() + API + destinationPath).query(gQuery).attach('file', file).end(function (error, result) { |
122 | if (result && result.statusCode === 403) return callback(new Error('Upload destination ' + destinationPath + ' not allowed')); | ||
123 | if (result && result.statusCode !== 201) return callback(new Error('Error uploading file: ' + result.statusCode)); | ||
122 | if (error) return callback(error); | 124 | if (error) return callback(error); |
123 | if (result.statusCode !== 201) return callback(new Error('Error uploading file: ' + result.statusCode)); | ||
124 | 125 | ||
125 | console.log('Uploaded to ' + config.server() + destinationPath); | 126 | console.log('Uploaded to ' + config.server() + destinationPath); |
126 | 127 | ||
@@ -128,7 +129,7 @@ function put(filePath, otherFilePaths, options) { | |||
128 | }); | 129 | }); |
129 | }, function (error) { | 130 | }, function (error) { |
130 | if (error) { | 131 | if (error) { |
131 | console.log('Failed to put file.', error); | 132 | console.log('Failed to put file.', error.message.red); |
132 | process.exit(1); | 133 | process.exit(1); |
133 | } | 134 | } |
134 | 135 | ||
@@ -143,9 +144,9 @@ function get(filePath) { | |||
143 | filePath = filePath || '/'; | 144 | filePath = filePath || '/'; |
144 | 145 | ||
145 | request.get(config.server() + API + filePath, { qs: gQuery }, function (error, result, body) { | 146 | request.get(config.server() + API + filePath, { qs: gQuery }, function (error, result, body) { |
147 | if (result && result.statusCode === 401) return console.log('Login failed'); | ||
148 | if (result && result.statusCode === 404) return console.log('No such file or directory %s', filePath.yellow); | ||
146 | if (error) return console.error(error); | 149 | if (error) return console.error(error); |
147 | if (result.statusCode === 401) return console.log('Login failed'); | ||
148 | if (result.statusCode === 404) return console.log('No such file or directory %s', filePath.yellow); | ||
149 | 150 | ||
150 | // 222 indicates directory listing | 151 | // 222 indicates directory listing |
151 | if (result.statusCode === 222) { | 152 | if (result.statusCode === 222) { |