Permalink
Browse files

don't use mirror when search. options on command line

  • Loading branch information...
1 parent 7332e4b commit f6e0b5543e3bde8918959e4d90d3ab654b87f75a Hsiaoming Yang committed Mar 27, 2013
Showing with 12 additions and 3 deletions.
  1. +1 −1 bin/spm-build
  2. +1 −0 bin/spm-info
  3. +1 −0 bin/spm-search
  4. +1 −0 bin/spm-unpublish
  5. +8 −2 lib/sdk/yuan.js
View
@@ -11,8 +11,8 @@ commander
.option('-O, --output-directory <dir>', 'output directory: [dist]')
.option('-v, --verbose', 'show more logs')
.option('-q, --quiet', 'show less logs')
+ .option('-f, --force', 'force to build')
.option('--encoding <encoding>', 'file encoding: [utf8]')
- .option('--force', 'force to build')
.option('--no-color', 'disable colorful print');
View
@@ -8,6 +8,7 @@ commander.usage('[options] family/name[@version]');
commander
.option('-s, --source <source>', 'default value will be the first source')
+ .option('-v --verbose', 'show more log')
.option('--no-color', 'disable colorful print');
View
@@ -8,6 +8,7 @@ commander.usage('[options] <query>');
commander
.option('-s, --source <source>', 'default value will be the first source')
+ .option('-v --verbose', 'show more log')
.option('--no-color', 'disable colorful print');
View
@@ -8,6 +8,7 @@ commander.usage('[options] family/name[@version]');
commander
.option('-s, --source <source>', 'default value will be the first source')
+ .option('-v --verbose', 'show more log')
.option('--no-color', 'disable colorful print');
View
@@ -43,7 +43,7 @@ function Yuan(options) {
Yuan.prototype.request = function(data, callback) {
data.url = util.format('%s/%s', this.server, data.urlpath);
- if (data.method.toLowerCase() === 'get') {
+ if (data.method.toLowerCase() === 'get' && data.urlpath.indexOf('repository/search') !== 0) {
// mirror is faster
data.url = util.format('%s/%s', this.mirror, data.urlpath);
}
@@ -92,7 +92,13 @@ Yuan.prototype.request = function(data, callback) {
callback(err);
return;
}
- body = JSON.parse(content.toString());
+ try {
+ body = JSON.parse(content.toString());
+ } catch(e) {
+ log.error('exit', 'parsing response error');
+ log.debug('html', content);
+ process.exit(2);
+ }
res.body = body;
callback(err, res, body);
});

0 comments on commit f6e0b55

Please sign in to comment.