0.2.0 • Published 12 years ago
cmdize v0.2.0
Cmdize
Convert normal js to CMD module.(What is CMD module? 中文定义)
It is a experimental project, being cautious to use it in important situation please!

Install
$ npm install cmdize -gUse in cli
There is a js file exmple.js:
window.abc = "abc";Cmdize it!
$ cmdize example.jsReading /Users/afc163/Desktop/example.js ...
No found any global variables.
cmdized.js is generated.
>> /Users/afc163/Projects/cmdize/cmdized.jsThen the cmdized.js would be generated:
define(function(require, exports, module) {
window.abc = "abc";
});Options
- clearGlobal
$ cmdize example.js --clear-globalIt will remove abc from window safely.
define(function(require, exports, module) {
window.abc = "abc";
try { delete window.abc } catch(e) { window.abc = null }
});In NodeJS
var cmdize = require('cmdize');
cmdize(code, options, function(result) {
// print cmdized code
console.log(result);
});

