Skip to content

Commit

Permalink
Upgrade spade to work with bpm 1.0.0.beta.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Jolley committed Jul 26, 2011
1 parent c1752f0 commit 513d637
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
9 changes: 7 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "spade",
"version": "1.0.0.2",
"version": "1.0.0.3",

"description": "Dependency Management Library for JavaScript",
"summary": "Dependency Management Library for JavaScript",
Expand All @@ -16,5 +16,10 @@
"qunit": "~> 1.0.0"
},

"bpm:transport": "spade/transport"
"bpm:provides": {
"transport": {
"main": "spade/transport"
}
}

}
25 changes: 22 additions & 3 deletions transport.js
@@ -1,15 +1,34 @@
/*globals BPM_PLUGIN */

BPM_PLUGIN.compileTransport = function(code, context, filename) {
var ret = '',
packageName = context['package'].name,
id = packageName+'/'+context.moduleId;

// Register package, probably a better way to do this
if (id.match(/^[^\/]+\/main$/)) {
ret += 'spade.register("'+packageName+'", '+JSON.stringify(context['package'])+');\n\n';

var ctx = context['package'],
pkg = { name: ctx.name,
version: ctx.version,
dependencies: ctx.dependencies };

ret += 'spade.register("'+packageName+'", '+JSON.stringify(pkg)+');\n\n';
}

if (context.settings['spade:format'] === 'function') {
code = 'function(require, exports, __module, ARGV, ENV, __filename){\n'+code+'\n}';
} else {
code = context.minify("(function(require, exports, __module, ARGV, ENV, __filename){\n"+code+"\n//@ sourceURL="+id+"\n})()");

var lines = code.split("\n");
lines[0] = lines[0].replace(/^\(function\([^\)]+\)\{/, '');
lines[lines.length-1] = lines[lines.length-1].replace(/\}\)\(\)$/, '');
code = lines.join("\n");
code = JSON.stringify(code);
}

// TOOD: We can also pass a string here, maybe we should instead
ret += 'spade.register("'+id+'", function(require, exports, __module, ARGV, ENV, __filename){\n'+code+'\n});';
ret += 'spade.register("'+id+'", '+code+');';

return ret;
};
Expand Down

0 comments on commit 513d637

Please sign in to comment.