Skip to content
This repository has been archived by the owner on Aug 15, 2018. It is now read-only.

Commit

Permalink
Merge pull request #938 from afc163/master
Browse files Browse the repository at this point in the history
improve performance of command line
  • Loading branch information
afc163 committed Aug 11, 2014
2 parents eb1dce1 + bb825f9 commit 8ee512f
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 52 deletions.
9 changes: 4 additions & 5 deletions bin/spm-build
Expand Up @@ -3,10 +3,9 @@
require('colorful').colorful();
var path = require('path');
var commander = require('commander');
var spm = require('..');
var build = spm.build;
var file = spm.sdk.file;
var log = spm.log;
var build = require('../lib/build');
var file = require('../lib/sdk/file');
var log = require('../lib/utils/log');

commander.usage('[options]');

Expand All @@ -28,7 +27,7 @@ if (commander.verbose) {
log.level = 'debug';
}

spm.log.config(commander);
log.config(commander);

console.log();
var cwd = path.join(process.cwd(), commander.inputDirectory || '');
Expand Down
6 changes: 3 additions & 3 deletions bin/spm-doc
@@ -1,7 +1,7 @@
#!/usr/bin/env node

var commander = require('commander');
var spm = require('..');
var doc = require('../lib/doc');
var file = require('../lib/sdk/file');
var log = require('../lib/utils/log');
require('colorful').colorful();
Expand Down Expand Up @@ -37,7 +37,7 @@ commander.on('--help', function() {

commander.parse(process.argv);

spm.log.config(commander);
log.config(commander);

if (!process.argv[2]) {
commander.help();
Expand All @@ -52,4 +52,4 @@ if (!pkg || !pkg.spm) {

console.log();

spm.doc(commander);
doc(commander);
9 changes: 4 additions & 5 deletions bin/spm-info
Expand Up @@ -2,11 +2,10 @@

require('colorful').colorful();
var commander = require('commander');
var spm = require('..');
var log = spm.log;
var info = spm.client.info;
var iduri = spm.sdk.iduri;
var print = spm.print;
var log = require('../lib/utils/log');
var info = require('../lib/client').info;
var iduri = require('../lib/sdk/iduri');
var print = require('../lib/utils/print');

commander
.usage('[options] name[@version]')
Expand Down
7 changes: 3 additions & 4 deletions bin/spm-install
Expand Up @@ -2,9 +2,8 @@

require('colorful').colorful();
var commander = require('commander');
var spm = require('..');
var install = spm.client.install;
var log = spm.log;
var install = require('../lib/client').install;
var log = require('../lib/utils/log');

commander
.usage('[options] name[@version]')
Expand Down Expand Up @@ -33,7 +32,7 @@ commander.on('--help', function() {
commander.parse(process.argv);

console.log();
spm.log.config(commander);
log.config(commander);

install({
registry: commander.registry,
Expand Down
5 changes: 2 additions & 3 deletions bin/spm-login
Expand Up @@ -4,9 +4,8 @@ require('colorful').colorful();
var commander = require('commander');
var inquirer = require('inquirer');
var spmrc = require('spmrc');
var spm = require('..');
var log = spm.log;
var login = spm.client.login;
var log = require('../lib/utils/log');
var login = require('../lib/client').login;

commander
.usage('[options]')
Expand Down
12 changes: 6 additions & 6 deletions bin/spm-publish
Expand Up @@ -2,10 +2,10 @@

require('colorful').colorful();
var commander = require('commander');
var spm = require('..');
var log = spm.log;
var publish = spm.client.publish;

var log = require('../lib/utils/log');
var client = require('../lib/client');
var publish = require('../lib/client').publish;
var upload = require('../lib/upload');
var file = require('../lib/sdk/file');

commander
Expand Down Expand Up @@ -45,12 +45,12 @@ if (commander.doc) {
log.error('miss', 'package.json or "spm" key');
process.exit(2);
}
spm.upload(commander, pkg);
upload(commander, pkg);
return;
}

log.info('publish', process.cwd());
log.info('target', spm.client.config().registry);
log.info('target', client.config().registry);
publish({
cwd: commander.inputDirectory,
tag: commander.tag,
Expand Down
9 changes: 4 additions & 5 deletions bin/spm-search
Expand Up @@ -2,10 +2,9 @@

require('colorful').colorful();
var commander = require('commander');
var spm = require('..');
var log = spm.log;
var print = spm.print;
var search = spm.client.search;
var log = require('../lib/utils/log');
var print = require('../lib/utils/print');
var search = require('../lib/client').search;

commander
.usage('[options] <query>')
Expand All @@ -30,7 +29,7 @@ if (!commander.args[0]) {
}

console.log();
spm.log.config(commander);
log.config(commander);

search({
name: commander.args[0]
Expand Down
4 changes: 2 additions & 2 deletions bin/spm-test
@@ -1,7 +1,7 @@
#!/usr/bin/env node

var commander = require('commander');
var spm = require('..');
var test = require('../lib/test');
require('colorful').colorful();
require('nico/lib/sdk/log').quiet = true;

Expand All @@ -24,4 +24,4 @@ if (!process.argv[1]) {
commander.help();
}

spm.test(commander);
test(commander);
15 changes: 6 additions & 9 deletions bin/spm-tree
@@ -1,15 +1,14 @@
#!/usr/bin/env node

require('colorful').colorful();
var path = require('path');
var resolve = path.resolve;
var commander = require('commander');
var archy = require('archy');
var spmrc = require('spmrc');
var log = require('../lib/utils/log');

require('colorful').colorful();
var spm = require('..');
var file = require('../lib/sdk/file');
var install = require('../lib/client').install;

commander
.option('-d, --depth <n>', 'set the depth to <n>', Infinity)
Expand All @@ -18,19 +17,17 @@ commander
commander.parse(process.argv);

// color
spm.log.config(commander);
log.config(commander);

var cache = {};
var file = spm.sdk.file;

var query = commander.args[0];

// handle "spm tree class"
if (query) {
// don't show spm install log message
log.quiet = true;
spm.install.fetch(query, function(err, dest) {
spm.install({
install.fetch(query, function(err, dest) {
install({
source: commander.source,
destination: dest + '/sea-modules/',
force: commander.force,
Expand Down Expand Up @@ -128,7 +125,7 @@ function lookup(paths, pkg) {
}
});
if (!pkgfile) {
spm.log.error('package', pkg.name + '@' + pkg.version + ' not found');
log.error('package', pkg.name + '@' + pkg.version + ' not found');
return null;
}
return pkgfile;
Expand Down
9 changes: 4 additions & 5 deletions bin/spm-unpublish
Expand Up @@ -3,10 +3,9 @@
require('colorful').colorful();
var commander = require('commander');
var inquirer = require('inquirer');
var spm = require('..');
var client = spm.client;
var iduri = spm.sdk.iduri;
var log = spm.log;
var client = require('../lib/client');
var iduri = require('../lib/sdk/iduri');
var log = require('../lib/utils/log');

commander
.usage('[options] name[@version]')
Expand All @@ -33,7 +32,7 @@ if (!commander.args[0]) {
}

console.log();
spm.log.config(commander);
log.config(commander);

var pkg = iduri.resolve(commander.args[0]);
if (!pkg) {
Expand Down
1 change: 0 additions & 1 deletion index.js
@@ -1,7 +1,6 @@
var util = require('util');
var EventEmitter = require('events').EventEmitter;
util.inherits(module.exports, EventEmitter);

exports = module.exports;
exports.version = require('./package').version;

Expand Down
4 changes: 2 additions & 2 deletions lib/doc.js
@@ -1,5 +1,5 @@
var path = require('path');
var spm = require('..');
var upload = require('./upload');
var spawn = require('win-spawn');
var nico = require('nico');
var DOC_PATH = '_site';
Expand Down Expand Up @@ -32,7 +32,7 @@ module.exports = function(commander, callback) {
if (commander.publish) {
cleanDoc();
nico.build(commander);
spm.upload({
upload({
doc: DOC_PATH,
registry: commander.registry
});
Expand Down
4 changes: 2 additions & 2 deletions lib/test.js
Expand Up @@ -2,7 +2,7 @@ var exeq = require('exeq');
var path = require('path');
var output = '_site/coverage.html';
var outputJSON = '_site/coverage.json';
var spm = require('..');
var doc = require('./doc');
var mochaBrowser = require('mocha-browser-for-spm');
var mo = require('../lib/sdk/module');
var file = require('../lib/sdk/file');
Expand All @@ -23,7 +23,7 @@ module.exports = function(config) {
console.log();
console.log(' Starting service for test runner ...'.to.cyan.color);

spm.doc({
doc({
server: true,
port: port
}, function() {
Expand Down

0 comments on commit 8ee512f

Please sign in to comment.