Skip to content

Commit

Permalink
fix install folder
Browse files Browse the repository at this point in the history
  • Loading branch information
yyfrankyy committed Jul 8, 2011
1 parent 7d985f8 commit ae3e52c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
14 changes: 9 additions & 5 deletions lib/spm/actions/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var factory = require('../lib/actionFactory'),
message = require('../i18n/message'),
jsp = uglifyjs.parser.parse,
pro = uglifyjs.uglify,
extract = require('../lib/extract'),
util = require('../../util');


Expand Down Expand Up @@ -76,7 +77,7 @@ Install.prototype.run = function(opts) {
seajs = fs.realpathSync('.');
}

util.readFromPath(CONFIG.REMOTE + CONFIG.DATAFILE, function(data) {
util.readFromPath(CONFIG.REGISTRY, function(data) {
data = data.replace(/define\(([\s\S]+)\);/, '$1');
try {
data = JSON.parse(data);
Expand Down Expand Up @@ -109,13 +110,16 @@ Install.prototype.run = function(opts) {

function install(meta, target, suffixes) {
var mod = meta.filename || meta.name, version = meta.version;
var remotefile = CONFIG.REMOTE +
path.join('modules', meta.name, version, mod);
var remotefile = CONFIG.SPMSERVER + path.join(meta.name, version, mod);

suffixes.forEach(function(suffix) {
var remote = remotefile + suffix,
local = path.join(target, mod + suffix);
util.download(remote, local, function() {
local = path.join(target, mod, version, mod + suffix);

util.mkdirSilent(path.join(target, mod));
util.mkdirSilent(path.join(target, mod, version));

util.download(remote, local, function(e) {
console.log('Installed %s@%s at %s.', mod, version, local);
});
});
Expand Down
6 changes: 3 additions & 3 deletions lib/spm/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

module.exports = {
PLACEHOLDER: '/*{{code}}*/',
MODULES_DIR: 'modules.seajs.com/modules',
MODULES_DIR: 'modules',
TRANSPORTS_DIR: 'transports',
DEFAULT_VERSION: '1.0.0',
ENABLE_ACTIONS: [
Expand All @@ -23,6 +23,6 @@ module.exports = {
ALIASES: {
rm: 'remove'
},
REMOTE: 'http://seajs.cloudfoundry.com/',
DATAFILE: 'registry'
SPMSERVER: 'http://modules.seajs.com/',
REGISTRY: 'http://seajs.cloudfoundry.com/registry'
};
8 changes: 7 additions & 1 deletion lib/spm/web/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ var fs = require('fs'),
* spm registry manager.
*/
var Registry = function(registry) {
this.registry = registry || 'modules.seajs.com/registry';
if (!registry) {
return;
}
this.registry = registry;
this.data = {};

try {
Expand All @@ -30,6 +33,8 @@ var Registry = function(registry) {
* update module into registry
*/
Registry.prototype.update = function(o, commit) {
if (!this.registry) return;

var self = this;

// is an array
Expand Down Expand Up @@ -62,6 +67,7 @@ Registry.prototype.remove = function(name, commit) {
* commit all update into registry
*/
Registry.prototype.commit = function() {
if (!this.registry) return;
try {
fs.writeFileSync(this.registry, JSON.stringify(this.data), 'utf-8');
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion modules

0 comments on commit ae3e52c

Please sign in to comment.